1. Instead of building a web server, you can consider to write a fastcgi
or scgi application.
2. You could look at the lua module. I hardly ever write C for nginx now.
http://openresty.org/ has some examples.
Also, I'm a big fan of using HTTP over things like fastcgi,scgi, etc.
Much easier to test, debug, etc. But that's just my opinion.
3. fcgiwrap http://wiki.nginx.org/Fcgiwrap
4. thttpd http://wiki.nginx.org/ThttpdCGI
Nginx doesn't support CGI.
The best solution probably depends on what you're trying to achieve and your particular circumstances. As well as the solutions already suggested, one method I've used is to build the C program against libevent, effectively using libevent to build a mini webserver that is running all the time. nginx can then use that as an upstream proxy.
libevent has all of the hard stuff done for you. You basically just need to use it's API to get hold of all the HTTP request information and to let it handle the response to the user.