cgi的写法
发布于 2007-12-05 19:57 2 阅读:60,425 评论:2 标签: C C++ Linux

      CGI虽然差不多已经被淘汰,但在大公司有时还是需要用到的。编写、编译和升级的确是件很麻烦的事情。

      个人感觉写CGI主要是两个方面,一个是头信息;一个是让服务器知道它是个CGI。头信息用“Content-type”指定;而要让服务器知道,则把文件放进服务器专门为CGI而准备的目录,否则会被服务器认为的个二进制文件。当然这个目录是可以自己指定的,对apache而言就是httpd.conf文件中“cgi-bin”的位置。

      下面是一个简单的C++例子:

以下是代码片段:

#include <iostream>

using namespace std;

main()
{
 cout << "Content-type: text/html; charset=gb2312\n\n";
 cout << "www.yayu.org" << flush;
 exit(0);
}

呵呵 要学的东西太多了都没时间

by pingye 2010-10-27 13:36:42
Warning: Trying to access array offset on value of type bool in /opt/bitnami/apache/htdocs/workingsmarty/templates_c/e21e83752348f01f75c472238af0e4512d51cc32_0.file.left_look.html.php on line 154

Warning: Trying to access array offset on value of type bool in /opt/bitnami/apache/htdocs/workingsmarty/templates_c/e21e83752348f01f75c472238af0e4512d51cc32_0.file.left_look.html.php on line 172
代码貌似有问题!嘎嘎

#include <iostream>
using namespace std;

int main()
{
cout << "Content-type: text/html; charset=gb2312\n\n";
cout << "www.yayu.org" << flush;

return 0;
}

建议读一下《高质量C++编程指南》

by sinper 2007-12-15 09:20:13
Warning: Trying to access array offset on value of type bool in /opt/bitnami/apache/htdocs/workingsmarty/templates_c/e21e83752348f01f75c472238af0e4512d51cc32_0.file.left_look.html.php on line 154

哎 偶一会C一会C++的 风格不统一

站长回复

Warning: Trying to access array offset on value of type bool in /opt/bitnami/apache/htdocs/workingsmarty/templates_c/e21e83752348f01f75c472238af0e4512d51cc32_0.file.left_look.html.php on line 172