我已经创建了一个打开控制台,并读取用户的输入的DLL ..读取用户输入:: cin.get
现在我有一个问题,读取用户的输入,当输入是列出的代码调用该函数的功能的价值..
这里是我的代码:
void UserTest::Menu() {
char UserInput[256];
centerstring(" <<- Functions ->>\n\n");
centerstring("<<- VEHICLE ->>\n");
centerstring("<<- KEYBIND ->>\n");
centerstring("<<- EXECUTE ->>\n");
centerstring("<<- CLEAR ->>\n");
std::cin.clear();
std::cin.sync();
std::cin.get(UserInput, 256);
if (UserInput == "CLEAR"){
UserTest::ClearConsole();
UserTest::Menu();
}else{
if (UserInput == "VEHICLE"){
centerstring("<<- VEHICLE ->>\n");
UserTest::PreCallVehicle(UserInput);
}else{
if (UserInput == ("EXECUTE")){
centerstring("<<- SCRIPT ->>\n");
UserTest::PreCallScript(UserInput);
}else{
if (UserInput == "KEYBIND"){
centerstring("<<- KEYBINDS ->>\n\n\n");
UserTest::PreCallKeybind();
}else{
UserTest::ClearConsole();
centerstring("<<- ERROR ->>\n");
}
}
}
}
}
是什么问题? – NathanOliver
当我在控制台中输入VEHICLE或任何其他列出的字符串时,我得到的是stringstring(“<< - ERROR - >> \ n”).. – 2291eefe
[可以在C++中使用!=和==来进行字符串比较写我自己?](http://stackoverflow.com/questions/19232814/can-i-use-and-in-c-for-string-comparison-without-writing-my-own) – NathanOliver