CGIProgramThe executable files are stored in the goahead/web/cgi-bin/directory, which can be directly compiled and generated using gcc. The webpage file is stored in the goahead/web/directory. The source file is as follows:
// Test. c
# Include <stdio. h>
# Include <stdlib. h>
Int main (void)
{
Char * data;
Long M, N;
Printf ("Content-Type: text/html/n ");
Printf ("<title> multiplication result </title> ");
Printf ("Data = getenv ("QUERY_STRING ");
If (Data = NULL)
Printf ("<p> error! Data is not input or there is a problem with data transmission ");
Else if (sscanf (data, "m = % LD & n = % lD", & M, & N )! = 2)
Printf ("<p> error! The input data is invalid. The number must be entered in the form. ");
Else
Printf ("<p> % LD and % ld: % lD. ", M, n, m * n );
Return 0;
}
// Test.html
<Form action = "/cgi-bin/test">
<Input name = "M" size = "5">
<Input name = "N" size = "5"> <br>
<Input type = "Submit" value = "OK">
</Form>
After compilation, run goaheadand execute the CGI program in ie‑test.html!