Guest_imported
New member
- Jan 1, 1970
- 0
- 0
- 0
OK- I just started my C++ class at school and found something interesting (BTW- I have NO prior experience with C++, just a little VB). We are using Borland C++ 3.1 also.
I cannot get an "if else" statement to process a string variable input by a user. No matter what is typed in, it seems to bypass the If statement and go directly to the "else" statement.
For example:
char name [20];
cout << "Enter Name:";
gets(name);
if (name == "Scott"
cout << "Correct";
else
cout << "Incorrect";
forgive me, I am doing this from memory, so my code may be a little off......but, what is the correct way to define a variable input by the user and then process that info??
I cannot get an "if else" statement to process a string variable input by a user. No matter what is typed in, it seems to bypass the If statement and go directly to the "else" statement.
For example:
char name [20];
cout << "Enter Name:";
gets(name);
if (name == "Scott"
cout << "Correct";
else
cout << "Incorrect";
forgive me, I am doing this from memory, so my code may be a little off......but, what is the correct way to define a variable input by the user and then process that info??