Im trying a simple code that has a user enter a specific name and if its not the name display a certain message but keep getting C2065 error saying the specific name I want entered is undeclared. Could someone show me what im doing wrong?
#include <iostream>
using namespace std;
int main()
{
char name[21];
cout << "What is your name?\n";
cin >> name;
if (name != Fake)
cout << "You are a imposter!!\n";
else
cout << "Hello sir!!!!!\n";
return 0;
}
String literals must be enclosed with quotation marks, i.e. "Fake"
And what you're trying to do won't work with char arrays. Replace it with a string (string name;) and make sure to include the <string> header.