On 3/5/07, debasish deka <[EMAIL PROTECTED]> wrote:
> You cannot use equality/inrquality operator here.
> Rather use strcmp() defined in <string.h>
Wrong. We are talking C++, you are talking C. The C++ string class can
use ==, <, >, etc.
> "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]
>
>
>
>
> To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.
> Yahoo! Groups Links
>
>
>
>
--
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
If I were to divulge it, it would overturn the world."
-- Jelaleddin Rumi