If you want to write cgi programs in c, cgicc may be helpful.
If you want to connect to the PostgreSQL server, you will use the libpq++ libraries provided with the PostgreSQL installation. Here is some sample code that uses the libraries to run a simple query: Base.cpp Makefile. Make a note of the library and include paths in the makefile.