469,925 Members | 1,519 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,925 developers. It's quick & easy.

HTML

Is it possible to use C or C++ to create web pages?

Ouputting text with HTML syntax is easy enough,
but how do I make a web browser see the generated
text?

Jul 19 '05 #1
6 2760

"Peter Morris" <no********@se.com> wrote in message
news:be**********@sparta.btinternet.com...
Is it possible to use C or C++ to create web pages?

Ouputting text with HTML syntax is easy enough,
but how do I make a web browser see the generated
text?


Sorry about the os-dependent reply, but this question is kind of
os-dependent (OP, please, next time, try to place this in a better
newsgroup). Just because I'm feeling nice:

(Assuming windows)

#include <fstream>
#include <stdlib.h>

int main()
{
using namespace std;

/* Output to text file the HTML stuff here */

system("iexplore <filename>");
}

Obviously, replace <filename> with whatever file you sent it to. This should
open up internet explorer to view the newly created file. Note that you need
to output this code to a file with a .htm or .html extention!

--
MiniDisC_2k2
To reply, replacenospam.com with cox dot net.
Jul 19 '05 #2

"Peter Morris" <no********@se.com> wrote in message
news:be**********@sparta.btinternet.com...
Is it possible to use C or C++ to create web pages?

Ouputting text with HTML syntax is easy enough,
but how do I make a web browser see the generated
text?


Just output it in the file and then start browser and tell it to read this
file.

Michael Furman

Jul 19 '05 #3

"Michael Furman" <Mi***********@Yahoo.com> wrote in message
news:be************@ID-122417.news.uni-berlin.de...

"Peter Morris" <no********@se.com> wrote in message
news:be**********@sparta.btinternet.com...
Is it possible to use C or C++ to create web pages?

Ouputting text with HTML syntax is easy enough,
but how do I make a web browser see the generated
text?


Just output it in the file and then start browser and tell it to read this
file.

Michael Furman


If that's all I wanted, I could just write the HTML file myself.

In Perl, for instance, I can write a script that outputs HTML.
If I run the script, it outputs the text to the screen. But I
can point Internet Explorer at the script, and it displays
a web page. This is dynamically generated, it varies according
to data read from a database.

I've written an application in perl, but I want to port it to
C++ or similar, using a complied executable instead of a
Perl script.

Jul 19 '05 #4
"Peter Morris" <no********@se.com> wrote in message
news:be**********@titan.btinternet.com...

"Michael Furman" <Mi***********@Yahoo.com> wrote in message
news:be************@ID-122417.news.uni-berlin.de...

"Peter Morris" <no********@se.com> wrote in message
news:be**********@sparta.btinternet.com...
Is it possible to use C or C++ to create web pages?

Ouputting text with HTML syntax is easy enough,
but how do I make a web browser see the generated
text?
Just output it in the file and then start browser and tell it to read
this file.


If that's all I wanted, I could just write the HTML file myself.

In Perl, for instance, I can write a script that outputs HTML.
If I run the script, it outputs the text to the screen. But I
can point Internet Explorer at the script, and it displays
a web page. This is dynamically generated, it varies according
to data read from a database.


I don't know how you've configured things, but that doesn't work for me
unless I access the Perl script through a web server. Is that what you're
getting at? You want your web server to run a C++ program and serve the
output to a web browser? If so, then it's just an issue of configuring your
web server. But that's off-topic here.
I've written an application in perl, but I want to port it to
C++ or similar, using a complied executable instead of a
Perl script.


FYI, if you're processing GET/POST requests, you might find this C++ CGI
library helpful:

http://www.cgicc.org/

You'll probably want to use some other non-standard library for accessing
your database.

In any case, it sounds like another newsgroup would be more helpful to you.
comp.infosystems.www.authoring.cgi, maybe.

--
Russell Hanneken
rh*******@pobox.com
Jul 19 '05 #5

On Thu, 10 Jul 2003, Peter Morris wrote:
"Peter Morris" <no********@se.com> wrote in message
Is it possible to use C or C++ to create web pages?

If that's all I wanted, I could just write the HTML file myself.

In Perl, for instance, I can write a script that outputs HTML.
If I run the script


via a CGI-BIN server or similar, I presume?
it outputs the text to the screen. But I
can point Internet Explorer at the script, and it displays
a web page. This is dynamically generated, it varies according
to data read from a database.
Depends on what support your host has for CGI. Geocities, for example,
doesn't have any. Point IE at a Perl script hosted there, and you
get a screenful of line noise. (Perl source, that is.) The same thing
happens if I point IE at a Perl script on my hard disk, although if
you have it configured differently, I've no doubt you could get a "CGI
server" on your own machine. I'd kind of like that. :)
I've written an application in perl, but I want to port it to
C++ or similar, using a complied executable instead of a
Perl script.


Look up the Perl equivalent of 'system()'. Then compile your C++
program to an executable (for whatever OS is running on your host
machine), and exec that program via a Perl script. Completely
untested and OT stuff follows:

% cat hello.cc

#include <iostream>
int main()
{ std::cout << "Hello world!" << std::endl; return 0; }

% cat hello.cgi
#!/usr/bin/perl

print "Content-type: text/html\n\n";
print `./hello`; ## Note the backquotes!

% g++ -o hello hello.cc
% chmod 755 hello.cgi

HTH,
-Arthur

Jul 19 '05 #6


Peter Morris wrote:
Is it possible to use C or C++ to create web pages?
of course, there is a cross platform C++ CGI toolkit
runs in C/C++ interpreter Ch.

http://www.softintegration.com/products/toolkit/cgi/

To access database, you write ODBC code which can
be used for any database in any OS.

ODBC information can be found in Microsoft MSDN, or
http://www.softintegration.com/products/toolkit/odbc/


Ouputting text with HTML syntax is easy enough,
but how do I make a web browser see the generated
text?


Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by cirillo_curiosone | last post: by
reply views Thread by Boris Ammerlaan | last post: by
9 posts views Thread by Patient Guy | last post: by
5 posts views Thread by serge calderara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.