プログラムでクラッシュが発生しましたが、それは問題ないように思えますが、もちろん、プログラムはそうではないと言っており、混乱しています。
私が現在取り組んでいる私の機能のこのスニペット:
for(int k = 0; k < dictionary[k].size(); k++)
{
//"i" represents the fragment's first character
//while "k" represents the dictionary first character
if(fragments[i][j] == dictionary[k][j]) {
token++;
cout << token << endl;
}
}
問題かもしれません。問題をデバッグすると、デバッガーはスニペットの最初の行に移動します。
for(int k = 0; k < dictionary[k].size(); k++)
次に行こうとするとクラッシュします。デバッガーでは、このウィンドウがコード ブロックで開きます。
Signal Received
Program Received Singal SIGEGV, segmentation fault. Do you want to view backtrace?
はいをクリックしましたが、それは私には恣意的に思えます。
私が間違ったことを誰か知っていますか?
バックトレースが必要な場合 (ウィンドウには Call Stack と表示されます)、後で必要に応じて編集します。
編集:これは機能全体であり、必要ではないと考えていました
void Language::compare()
{
int para = getParameters(0); //eg. 3
int valid = para;
int token = 0;
for(int i = 0; i < para; i++)
{
//If the string is creater than 2 characters
if(fragments[i].length() > 1) {
for(int j = 0; j < fragments[i].length(); j++)
{
//Checking if that character match in dictionary
for(int k = 0; k < para; k++) //Changed and now works,
{
//"i" represents the fragment's first character
//while "k" represents the dictionary first character
if(fragments[i][j] == dictionary[k][j]) { //But now this line crashes
token++;
cout << token << endl;
}
}
if(token == 0) {
break;
}
}
}
else {
//...
}
}
}
辞書とフラグメントは、どちらもベクトルであるクラス「Language」で宣言されています。