私はC/C ++ゲームに慣れていないので、新人の間違いを犯していると思います。
int main(){
char* clen;
clen = getenv("CONTENT_LENGTH");
if (clen==NULL){
cout << "No such ENV var: CONTENT_LENGTH"<<endl;
exit(0);
}
int cl = 0;
cl = atoi(clen);
if (cl < 1){
return inputPage();
}
// if there is no content, we assume that this is a fresh request,
// so we showed the input page, otherwise, we'll return dispatch to
//the processing code.
postTest(clen);
}
これはCGIスクリプトであると想定されています。GDB、printステートメントなどでわかる限り、このコードは「cl = atoi(clen);」の行でsegfaultsします。なぜなのかわかりません。K&Rは、これが正しいことを示唆しています。私は基本的に、この行を他の6つのオンラインチュートリアルからコピーしました。そして、それは昨夜働いているようでした!私は完全に困惑しています。