Guest_imported
New member
- Jan 1, 1970
- 0
hi,
> i am writing a cgi-c program and the input from the browser is sent to
> stdin. i have to retrive the input from stdin and use it.
> here is my sample code.
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> main()
> {
> float min,max;
> int len;
> char *input,*lenstr;
> //content_length gives the length of input..
>
> lenstr=getenv("CONTENT_LENGTH"
> printf("<content-type:text/html\n\n>"
> len=atoi(lenstr);
> fgets(input,len+1,stdin);
> sscanf(input,"T1=%f&T2=%f",&min,&max);
> printf("<html><body>minimum=%f and maximum=%f",min,max);
> printf("</body></html>"
> }
> program works fine till it encounters fgets statment. then it says segementation
> fault, core dumped etc..i am working on unix platform and using gcc compiler.
> any help will be appreciated..
> lucifer...
> i am writing a cgi-c program and the input from the browser is sent to
> stdin. i have to retrive the input from stdin and use it.
> here is my sample code.
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> main()
> {
> float min,max;
> int len;
> char *input,*lenstr;
> //content_length gives the length of input..
>
> lenstr=getenv("CONTENT_LENGTH"
> printf("<content-type:text/html\n\n>"
> len=atoi(lenstr);
> fgets(input,len+1,stdin);
> sscanf(input,"T1=%f&T2=%f",&min,&max);
> printf("<html><body>minimum=%f and maximum=%f",min,max);
> printf("</body></html>"
> }
> program works fine till it encounters fgets statment. then it says segementation
> fault, core dumped etc..i am working on unix platform and using gcc compiler.
> any help will be appreciated..
> lucifer...