私のC++プログラムは、main()からこの関数を呼び出すまでコンパイルされ、動作します。
int uword(){fstream infile("numbers.txt");
fstream exfile("wordlist.txt");
string numb[numoflines];
string lines[numoflines];
number = 1;
line = 1;
for(int i=0;i<numofline;++i)
{
getline (infile,number);
numb[i] = number; //I think this is causing the problem
getline (exfile,line);
lines[i] = line; //This too
}
infile.close();
exfile.close();
string yourword;
ここで何かが原因でクラッシュします。デバッグでは、「プログラムでアクセス違反(セグメンテーション違反)が発生しました」というメッセージが表示されます。
編集:私の間違いは、forループで!infile.eofを使用していたことです。