What you want is CGIC: http://www.boutell.com/cgic/
You can also Google for:
cgi c example [www.google.com]
Important: HTTP headers should end with \r\n, not \n (this is done very often). So, instead of writing code like:
printf("Content-Type: text/html\n");
you should use:
printf("Content-Type: text/html\r\n");
And to end a HTTP header, you must use \r\n\r\n and NOT \n\n. If you have no idea what I'm talking about, don't worry. Just visit the CGIC website and start reading. Very soon you'll understand what I mean.