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.
This is a discussion on CGI String Format within the A Brief History of Cprogramming.com forums, part of the Community Boards category; a) Is the string passed to the ci file from a web site null terminated, or does it just END. ...
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.
>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:
-PreludeCode:#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; }
My best code is written with the delete key.