I'm not sure about any documents out there, but really all a CGI program has to do is print "Content-type: text/html\n\n" at the beginning, then anything you print to stdout will go to the client's web browser. Below is a simple C program that prints an ordered list of 0 through 9.
Code:
#include <stdio.h>
int main( int argc, char* argv[] )
{
int i = 0;
printf( "Content-type: text/html\n\n" );
printf( "<html>\n" );
printf( "<head>\n" );
printf( "<title>\n" );
printf( "This is a test of doing CGI from C.\n" );
printf( "</title>\n" );
printf( "</head>\n");
printf( "<body>\n" );
printf( "<p>Here's how you make an ordered list:\n" );
printf( "<ol>\n" );
for( i=0; i < 10; i++ ) {
printf( "<li>%d\n", i );
}
printf( "</ol>\n" );
printf( "</body>\n" );
printf("</html>\n");
return( 0 );
}
Compile it, and make sure it has correct executable permissions:
Code:
gcc -o foo.cgi foo.c
chmod 755 foo.cgi
Then access it from the web browser (e.g.
http://www.bitbreather.com/~eric.r.turner/foo.cgi ).
If I were doing this sort of thing for a real-world environment (and had to use C or C++) I'd probably use C++ and create classes that print themselves correctly. Something like:
Code:
OrderedList* numberRange = new OrderedNumberRange(0,9);
cout << *numberRange << endl;