codescracker


c++

C++ Web Programming



« Previous Tutorial CodesCracker Home »


CGI

CGI stands for Common Gateway Interface, is a set of standards that defines how information is exchanged between the web server and a custom script.

First CGI Program

Here is the first CGI program given

/* C++ Web Programming - Example Program */
		
#include<iostream.h>
#include<conio.h>
void main()
{
	clrscr();
	cout<<"Content-type:text/html\r\n\r\n";
	cout<<"<html>\n";
	cout<<"<head>\n";
	cout<<"<title>First CGI Program</title>\n";
	cout<<"</head>\n";
	cout<<"<body>\n";
	cout<<"<h2>Hello World, This is my first CGI Program.</h2>\n";
	cout<<"</body>\n";
	cout<<"</html>\n";
	getch();
}

Compile the above C++ code and name the executable as cplusplus.cgi. This file is being kept in the /var/www/cgi-bin directory. Before running your first CGI program, please make sure that you have change mode of file using chmod 755 cplusplus.cgi UNIX command to make file executable. Now if you click on cplusplus.cgi then it will produce the following output:

Hello World, This is my first CGI Program.

This is just a simple clue, how web programming can be performed in C++.


« Previous Tutorial CodesCracker Home »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test