|
Hello World Example
The example programs shown below illustrate the C and C++ statements required
for the Hello, World programming assignment.
Use both of these as examples for creating the C and C++ programs (named
hello.c and hello.cpp
respectively) which satisfy the assignment requirements.
#include <stdio.h>
/* hello.c : a simple CGI example. */
int main()
{
/* First indicate the content type of the document; in this
case we are outputting HTML. Note that we output
TWO carriage returns after the content type. This is important! */
printf("Content-type: text/html\n\n");
/* Output an HTML document, with all necessary HTML tags. */
printf("<html>\n");
printf("<head>\n");
printf("<title>Hello, World Using C++</title>\n");
printf("</head>\n");
printf("<body>\n");
printf("<h1>Hello, World</h1>\n");
printf("<p>This is my first CGI program!\n");
printf("<p>It is written in C style code.\n");
printf("</body>\n");
printf("</html>\n");
return 0;
}
#include <iostream.h>
// hello.cpp : a simple CGI example.
int main()
{
// First indicate the content type of the document; in this
// case we are outputting HTML. Note that we output
// TWO carriage returns after the content type. This is important!
cout << "Content-type: text/html" << endl << endl;
// Output an HTML document, with all necessary HTML tags.
cout << "<html>" << endl;
cout << "<head>" << endl;
cout << "<title>Hello, World Using C++</title>" << endl;
cout << "</head>" << endl;
cout << "<body>" << endl;
cout << "<h1>Hello, World</h1>" << endl;
cout << "<p>This is my second CGI program!" << endl;
cout << "<p>It is written in C++ style code." << endl;
cout << "</body>" << endl;
cout << "</html>" << endl;
return 0;
}
There have been
visitors since 11/26/2003
|