Passing a string from php to c using exec()

This is a discussion on Passing a string from php to c using exec() within the C Programming forums, part of the General Programming Boards category; I am trying to pass a string as a parameter from PHP to a c file, using exec() Here's the ...

  1. #1
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153

    Passing a string from php to c using exec()

    I am trying to pass a string as a parameter from PHP to a c file, using exec()
    Here's the PHP:
    Code:
    $mystring = "foobar";
    echo exec('./cairo21 -a $mystring');
    That goes fines.
    The problem is when I am trying to accept the string into my compiled c file:
    C Code:
    Code:
    char webcompanyname[256] = getopt(argc,argv, "a:");
    Compiler: error: invalid initializer
    cairo21.c:69:2: warning: initialization makes integer from pointer without a cast.
    Apparently getopt returns an integer. Is that integer a pointer to the string? Thoughts greatly appreciated.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    Quote Originally Posted by javaeyes
    Apparently getopt returns an integer. Is that integer a pointer to the string?
    Read the manual, e.g., getopt.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 10-24-2011, 12:35 PM
  2. Passing filename as a string
    By qxcdfg in forum C++ Programming
    Replies: 2
    Last Post: 03-11-2008, 06:46 AM
  3. Passing an 8-bit String
    By slowcoder in forum C Programming
    Replies: 8
    Last Post: 08-01-2006, 07:18 AM
  4. Need Help passing a string from VB into a C++ DLL??
    By dan Burke in forum C++ Programming
    Replies: 4
    Last Post: 04-28-2004, 09:15 AM
  5. Passing string to function
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 11-21-2001, 05:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21