このコードは、コメントを外した場合にのみ機能します
//else return "null";
9行目ですが、それは私が必要とするものではありません。その行を次のように置き換えてみました
else continue;
しかし、それもうまくいきません。「currentCommand」は C スタイルの文字列です。
std::string Parser::dest(){
//Determines whether C-command has a dest mnemonic
bool hasDest = false;
for (int i=0; i<strlen(currentCommand); i++){
if (currentCommand[i] == '='){
hasDest = true;
break;
}
//else return "null";
}
if (hasDest == false) return "null";
std::string destm;
char temp;
int index = 0;
temp = currentCommand[index];
while (temp != '='){
destm += temp;
index++;
}
return destm;
}
この関数を呼び出すと出力が得られるはずでしたが、コメントを外すと得られ//else return "null"
ます..しかし、必要な出力ではありません。しかし、その行をコメントのままにしておくと、出力が得られず、しばらくすると次のエラーが表示されます。
「std::bad_alloc」のインスタンスをスローした後に呼び出される終了
what(): std::bad_alloc
1Aborted (コアダンプ)