Brett W. McCoy a écrit :
> On 04 Mar 2007 15:59:52 -0800, len_kim <[EMAIL PROTECTED]> wrote:
>
>
>> I am unable to get the below program to evaluate the string that is
>> entered for the name. Can someone tell me what I am doing wrong and
>> if it is even possible to run an "if" statement and make it evaluate
>> a string?
>>
>> #include <iostream>
>> #include <string>
>> using namespace std;
>> int main()
>> { string name;
>> cout << "Please enter your name ";
>> cin >> name;
>> if (name == 'John')
>> cout << "Your name is John ";
>> else
>> cout << "Your name is not John ";
>> return 0;
>>
>
> name == "John" <-- use double quotes
>
> you can also use
>
> name.compare("John")
>
>
perhaps, !name.compare( "John" ) for equality.