Thread: CGI String Format

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912

    CGI String Format

    a) Is the string passed to the ci file from a web site null terminated, or does it just END.

    b) how do you get it into the file? Is it like this:

    char anyname[CONTENT_LENGTH];
    scanf(anyname);

    If not, HOW!?

    Thanksin advance if you can help.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Is the string passed to the ci file from a web site null terminated, or does it just END.
    String input works the same with CGI as with anything else, both with stdin and arguments to main.

    >how do you get it into the file?
    The easiest way is to read a string and then parse it. fgets is ideal for this. You can also use argc and argv:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #define OPEN "<HTML><BODY>"
    #define CLOSE "</BODY></HTML>"
    
    int main ( int argc, char **argv )
    {
      char msg[BUFSIZ];
      if ( argc > 1 )
        parseMsg ( msg, argv[1] );
      printf ( "Content-type: text/html\n\n" );
      printf ( "%s\n%s\n%s\n", OPEN, msg, CLOSE );
      return EXIT_SUCCESS;
    }
    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 03:40 AM
  2. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  3. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  4. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM
  5. Again Character Count, Word Count and String Search
    By client in forum C Programming
    Replies: 2
    Last Post: 05-09-2002, 11:40 AM