0
使用此代码时,它会抛出一个未处理的写入异常,我几乎可以肯定是使用atoi()函数。C++ - 使用atoi()时出现未处理的异常
while(true){
char* item = "";
cin >> item;
int numItem = atoi(item);
if(numItem){
if(numItem<=backpackSpaces){
equipItem(backpack[numItem]);
break;
}else{
cout << "No such item." << endl;
}
}else if(item == "back"){
cout << "Choose an option from the original choices. If you can't remember what they were, scroll up." << endl;
break;
}else{
cout << "Command not recognised." << endl;
}
}
我知道有一个数组在其中。>。谢谢 – pighead10 2011-03-26 15:19:27
更好的是,使用'std :: string'。 – 2011-03-26 15:20:48
现在如果我输入'back',它会输出'Command not recognized'命令? – pighead10 2011-03-26 15:24:48