Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 脚本头过早结束:CGI+;C++;_C++_Apache_Cgi - Fatal编程技术网

C++ 脚本头过早结束:CGI+;C++;

C++ 脚本头过早结束:CGI+;C++;,c++,apache,cgi,C++,Apache,Cgi,我甚至不能得到一个使用CGI的简单测试程序。这是我的密码。当我在控制台中运行它时,它会工作,但当我尝试从Apache运行时,它会给出错误: #include <iostream> #include <stdio.h> #include <stdlib.h> int main() { printf("Content-type: text/html\n\n"); printf("TEST"); return 0; } 错误: [Thu

我甚至不能得到一个使用CGI的简单测试程序。这是我的密码。当我在控制台中运行它时,它会工作,但当我尝试从Apache运行时,它会给出错误:

#include <iostream>
#include <stdio.h>
#include <stdlib.h>

int main() {
    printf("Content-type: text/html\n\n");
    printf("TEST");
    return 0;
}
错误:

[Thu Mar 22 19:14:23 2012] [error] [client 127.0.0.1] Premature end of script headers: e2.exe
在命令提示符下运行:

C:\Users\Stephen>C:\wamp\www\e2.exe
Content-type: text/html

TEST
任何帮助都将不胜感激!谢谢

已解决:生成文件:

build: source/main.cpp
    C:/MinGW/bin/gcc.exe -o build/e2.exe source/main.cpp
build: source/main.cpp
    C:/MinGW/bin/gcc.exe -o build/e2.exe source/main.cpp
已解决:生成文件:

build: source/main.cpp
    C:/MinGW/bin/gcc.exe -o build/e2.exe source/main.cpp
build: source/main.cpp
    C:/MinGW/bin/gcc.exe -o build/e2.exe source/main.cpp
GCC不是G++

已解决:生成文件:

build: source/main.cpp
    C:/MinGW/bin/gcc.exe -o build/e2.exe source/main.cpp
build: source/main.cpp
    C:/MinGW/bin/gcc.exe -o build/e2.exe source/main.cpp

GCC不是G++

HTTP行结尾是
\r\n
@KerrekSB:我想知道区别。对它有进一步的了解吗?不超过这一行的结尾:-),但说真的,这只是协议规范的一部分。如果你敢的话,你可以读RFC。为什么要读RFC,而一些很酷的人可以为你总结:MinGW不使用Windows样式的行结尾吗?由于OP在Windows上工作,因此\n应转换为CRLF。我已经用DEV-C++(不记得后面的C++编译器)检查过了,并且使用了PrtTf(ABC\N\N);给我两个CRLF,而printf(“abc%c%c”,13,13);只给我两个CR。HTTP行结尾是
\r\n
@KerrekSB:我想知道区别。对它有进一步的了解吗?不超过这一行的结尾:-),但说真的,这只是协议规范的一部分。如果你敢的话,你可以读RFC。为什么要读RFC,而一些很酷的人可以为你总结:MinGW不使用Windows样式的行结尾吗?由于OP在Windows上工作,因此\n应转换为CRLF。我已经用DEV-C++(不记得后面的C++编译器)检查过了,并且使用了PrtTf(ABC\N\N);给我两个CRLF,而printf(“abc%c%c”,13,13);只给我两个CR。