この HelloWorld CGI C++ プログラムで誰かが私を助けてくれることを願っています。localhost で Xamp サーバーを実行しており、このコードを /xamp 内の cgi-bin フォルダーにコンパイルしました。ファイル名は_1.exeです
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
cout <<"Content-Type: text/html\n\n";
cout << "<?xml version = \"1.0\" encoding=\"ISO-8859-1\"?>" <<endl;
cout <<"<!DOCTYPE html Public \"-//W3C//DTD XHTML 1.1//EN\" "<<endl;
cout << " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"<<endl;
cout <<"<html xmlns = \"http://www.w3.org.1999/xhtml\lang=\"en\" xml:lang=\"en\"\">"<<endl;
cout <<"<head><title>Helloworld</title></head>"<<endl;
cout <<"<body><h1>Hello world!!</h1></body></html>";
return 0;
}
実行可能ファイルは Windows から実行されますが、サーバーから呼び出すと、次のようになります。
Error message:
Premature end of script headers: _1.exe
Netbeans と cygwin ツールでコンパイルしています。
ファイルの名前も_1.cgiに変更しようとしました