954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

CGI with C/C++

Hello folks,
I have a working CGI written in C. It uses the printf statement to build the outgoing HTML web page. I understand that printf is actually outoutting to the STDOUT device. I'd like to use the WriteFile statement to build the outgoing page and I've tried this:-

WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), &input, byt2wrt, &numwrt, NULL);

and it writes to the console OK when run under the VC++ IDE but fails in the CGI prog. I get Premature end of script headers: gencde.exe, referer: http://. .. in the Apache logfile.

Can anyone help me on this please?
Ta

turnbui
Newbie Poster
6 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

my guess is the computer that runs the cgi program does not have .NET framefork installed or the wrong version. Use either fprintf() or cout and you won't have that problem.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

It has Net 1.1 ? Is this the wrong version. Why does it need this to write to the STDOUT? Not certain I understand this.
Cheers

turnbui
Newbie Poster
6 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

Here http://www.cs.tut.fi/~jkorpela/forms/cgic.html is one of probably many tutorials. stdout is treated in a special way in a web server, which redirects it back to the web browser. I don't know enough of the details to tell you much more -- just google for "cgi c programs" and you will get more information.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You