RE: [Dev-C++] I am new to C ++ and need some help
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ya...> - 2000-12-12 03:34:01
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...]On Behalf Of
> prakyath pai
> Sent: Monday, December 11, 2000 11:47 AM
> To: dev...@li...
> Subject: RE: [Dev-C++] I am new to C ++ and need some help
>
>
> hey u used the wrong logic!
> you cannot use the statement
> if(char c=='bruce')
> {cout<<"Thankk You";
> you will have to use the following commands:-
>
> #include<string>
> char c[25];
> cout<<"enter your name";
> if(strcmp(c,"bruce")==0)
> cout<<"Thank You";
> else
> cout<<"You are not granted access";
> exit(0);
> }
In fact the following stuff can be used in C++ only.
char s1[20], s2[20];
...
if(s1==s2)
...
The overloaded string operator == accepts 2 strings (objects) and the
C-style strings are "upgraded" to temporary strings so as the comparison to
work.
But the better is string s1, s2; to be used instead (including the
<string>).
Ioannis
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
|