#include <iostream>
int main()
{
char username[15];
char password[15];
std::cout << "Hello, please login to continue your action.<Max 15 Char>" << std::endl;
std::cout << "Username: ";
std::cin >> username;
std::cout << "Password: ";
std::cin >> password;
if (username == "User" && password == "qwerty")
{
std::cout << "Hello, creator.";
}
else
{
std::cout << "Invalid Login";
}
/*23 row*/ std::cout << std::endl << std::endl << "Username=" <<username << std::endl << "Password=" << password;
std::cout << std::endl << std::endl << "Press Enter to close the window . . . ";
std::cin.clear();
std::cin.sync();
std::cin.get();
}
當我輸入正確的時候應該說你好造物主,但它只會失效,我認爲也許只有1 char這就是爲什麼在第23行我看起來是什麼存儲在char用戶名和密碼,但一切都很好。那麼爲什麼需要Else {...}句子?C++字符或邏輯運算符?爲什麼需要{...}如果正確?
使用的std :: string字符串comparisation – 2012-03-11 19:07:47