#include < cstdio>
#include < cstdlib>
#include < iostream>
#include < string>
using namespace std;
int main ( int nNumberofArgs, char* pszArgs[])
{
string name;
string password;
int ans1;
printf("Turn on the BEDrive??\n(write an ODD number for 'no' and EVEN 'yes'\n");
cin >> ans1;
while(ans1%2==0)
{
printf("Hello Master... Welcome to the BEDrive System...\nwould you like to login...\n);
cin.ignore(10, '\n');
cin.get();
printf("Enter your login ID: ");
cin >> name;
printf("Enter your password: ");
cin >> password;
if(name = "smartyguy1" && password = "Bhanuhanu1")
{
printf("WELCOME MASTER!!!!.\nDo you want to change your password(y/n)?");
}
else
{
printf("Login FAILED!!!:( ");
}
return 0;
}
}
当我编译此代码时,它显示错误:'operator &&'不匹配(操作数类型为'const char [11]'和'std :: __ cxx11 :: string {aka std :: __ cxx11 :: basic_string}' )请帮我解决这个问题
答案 0 :(得分:0)
您的代码中有一些错误。我帮你修好了 您错过了第30行的结尾。
#include <cstdio> // "< cstdio>" is not correct, no space is allowed here
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main ( int nNumberofArgs, char* pszArgs[])
{
string name;
string password;
int ans1;
printf("Turn on the BEDrive??\n(write an ODD number for 'no' and EVEN 'yes'\n");
cin >> ans1;
while(ans1%2==0)
{
printf("Hello Master... Welcome to the BEDrive System...\nwould you like to login...\n"); // you missed ending " here
cin.ignore(10, '\n');
cin.get();
printf("Enter your login ID: ");
cin >> name;
printf("Enter your password: ");
cin >> password;
if(name == "smartyguy1" && password == "Bhanuhanu1")
{
printf("WELCOME MASTER!!!!.\nDo you want to change your password(y/n)?");
}
else
{
printf("Login FAILED!!!:( ");
}
return 0;
}
}