Click here to Skip to main content
15,891,431 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalreal simple question Pin
5-Mar-02 15:32
suss5-Mar-02 15:32 
GeneralRe: real simple question Pin
alex.barylski5-Mar-02 16:02
alex.barylski5-Mar-02 16:02 
GeneralRe: real simple question Pin
Michael Dunn5-Mar-02 16:28
sitebuilderMichael Dunn5-Mar-02 16:28 
GeneralRe: real simple question Pin
5-Mar-02 16:42
suss5-Mar-02 16:42 
GeneralRe: real simple question Pin
alex.barylski5-Mar-02 17:53
alex.barylski5-Mar-02 17:53 
GeneralRe: real simple question Pin
Todd.Harvey6-Mar-02 9:13
Todd.Harvey6-Mar-02 9:13 
QuestionWhats wrong with this? Pin
SilverShalkin5-Mar-02 14:01
SilverShalkin5-Mar-02 14:01 
AnswerRe: Whats wrong with this? Pin
Lofote5-Mar-02 14:26
Lofote5-Mar-02 14:26 
Uh, a lot. First of all, "char" is a single character, not a whole string. You need to do an char array for a complete string, or use a CString from MFC. Second, you can't compare char arrays with the "==" symbol, you need to use "strcmp" ("==" does work for CStrings however).

So, correct code would look something like this:

char r[256]; //note that if user inputs more than 255 characters, program might crash
gets(r);
if(strcmp(r,"ok")==0)
{
cout << ("good job");
}

Cya (c:
GeneralRe: Whats wrong with this? Pin
Christian Graus5-Mar-02 14:27
protectorChristian Graus5-Mar-02 14:27 
GeneralRe: Whats wrong with this? Pin
SilverShalkin5-Mar-02 14:49
SilverShalkin5-Mar-02 14:49 
GeneralRe: Whats wrong with this? Pin
Jon Sagara5-Mar-02 14:49
Jon Sagara5-Mar-02 14:49 
GeneralRe: Whats wrong with this? Pin
Rohit  Sinha5-Mar-02 15:11
Rohit  Sinha5-Mar-02 15:11 
GeneralRe: Whats wrong with this? Pin
Jon Sagara5-Mar-02 15:25
Jon Sagara5-Mar-02 15:25 
GeneralRe: Whats wrong with this? Pin
Tim Smith5-Mar-02 15:30
Tim Smith5-Mar-02 15:30 
GeneralRe: Whats wrong with this? Pin
Jon Sagara5-Mar-02 15:36
Jon Sagara5-Mar-02 15:36 
GeneralRe: Whats wrong with this? Pin
Christian Graus5-Mar-02 14:56
protectorChristian Graus5-Mar-02 14:56 
GeneralRe: Whats wrong with this? Pin
Tim Smith5-Mar-02 15:09
Tim Smith5-Mar-02 15:09 
GeneralRe: Whats wrong with this? Pin
Christian Graus5-Mar-02 15:14
protectorChristian Graus5-Mar-02 15:14 
GeneralRe: Whats wrong with this? Pin
Tim Smith5-Mar-02 15:17
Tim Smith5-Mar-02 15:17 
GeneralRe: Whats wrong with this? Pin
SilverShalkin5-Mar-02 14:57
SilverShalkin5-Mar-02 14:57 
GeneralRe: Whats wrong with this? Pin
Jon Hulatt6-Mar-02 5:41
Jon Hulatt6-Mar-02 5:41 
AnswerRe: Whats wrong with this? Pin
Michael Dunn6-Mar-02 7:37
sitebuilderMichael Dunn6-Mar-02 7:37 
GeneralRe: Whats wrong with this? Pin
Lofote6-Mar-02 8:05
Lofote6-Mar-02 8:05 
GeneralOnChildNotify() Pin
5-Mar-02 14:03
suss5-Mar-02 14:03 
GeneralRe: OnChildNotify() Pin
paulb5-Mar-02 16:15
paulb5-Mar-02 16:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.