How to Run a CPP CGI Script on the Web
Most Web scripts are executed by Web servers running embedded interpreters for languages such as PHP or Ruby. These languages work well with Web apps but come at a price in that they are not as time or memory efficient as other programming languages. Programmers who have a handle on compiled languages such as C++, however, can also build their own CGI scripts. With the Apache Web server software system installed you can run C++ scripts as a CGI script and get the result to your Web browser.
Instructions
-
-
1
Write a C++ CGI file as follows and save it under the name "test.cpp":
#include <iostream>
using namespace std;int main(){
cout<<"Content-type: text/plain"<<endl<<endl;
cout<<"Hello World!"<<endl;return 0;
} -
2
Save the file to the cgi-bin directory of your Apache Web Server. This folder contains all the cgi files the server will run.
-
-
3
Point your Web browser to the file in the cgi-bin folder, which is usually something similar to "http://localhost/cgi-bin/test.ccp", depending on the platform.
-
1