You cannot use equality/inrquality operator here.
Rather use strcmp() defined in <string.h>

"Brett W. McCoy" <[EMAIL PROTECTED]> wrote:                                  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")
 
 -- Brett
 ----------------------------------------------------------
 "In the rhythm of music a secret is hidden;
     If I were to divulge it, it would overturn the world."
                -- Jelaleddin Rumi
 
     
                       


Karmennevaya Dhikaraste, Maaphaaleshu Kadaachanah
                                
---------------------------------
 Here’s a new way to find what you're looking for - Yahoo! Answers 

[Non-text portions of this message have been removed]

Reply via email to