Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie wants to print 2

Status
Not open for further replies.

sleuth

Programmer
Jan 12, 2001
134
US

Hello,

Ok, I'm a perl programmer so this shouldn't be too hard,

All I need to know for now is how I can print hello world through the browser, in perl it's as simple as printing Content-type: text/html\n\n but in c++ there must be an include I need to use, no one's been able to tell me either, what gives!

Ok, so I need to print hello world, then I'll compile the program, then I should be able run it through the browser on the server.

If someone could please point me in the right direction to acomplish that, then my perl expirience should make the rest of my c++ life easier, hehe.

Thanks A Million C folks,

Tony "Java?? Umm, I think that's the stuff I drink while I'm coding perl."
 
I am not sure if I completely follow what you are trying to do. Do you just want to write to a file, for example HelloWorld.htm and then be able to open that file with a browser?

If that is the case you want to

#include <fstream.h>
...
ofstream outFile(&quot;HelloWorld.htm&quot;);
outFile<< *insert html tags here*;
outFile<<&quot;Hello World\n&quot;;
outFile<< *closing html tags*
...


and then open HelloWorld.htm with the browser. Not sure if this is what you mean though

Matt
 
I think he's asking how to write a simple CGI program in C++.

#include <iostream>

using std::cout;

int main()
{
cout << &quot;Content-type: text/html&quot; << endl << endl;
cout << &quot;<HTML><HEAD><TITLE>Hello, World!</TITLE></HEAD></HTML>&quot; << endl;
return 0;
}

If you're having trouble getting your web server to execute a C++ program, you might need to change its configuration.

Russ
bobbitts@hotmail.com
 
Great!

Thanks Russ, that really helps, that's exactly what I was trying to do.

Thanks for the post too Matt.

I shouldn't have any trouble running the compiled versions of my simple coding on the server, I know that my cgi-bin is set for executables.

Thanks Again,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top