我已經創建了一個打開控制檯,並讀取用戶的輸入的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