cin question

This is a discussion on cin question within the C++ Programming forums, part of the General Programming Boards category; What's wrong with this? Code: char cmd[80]; cin.getline(cmd, 80); if (cmd == "help") { cout << "No help available." << ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    5

    cin question

    What's wrong with this?

    Code:
    char cmd[80];
    cin.getline(cmd, 80);
    
    if (cmd == "help") {
    cout << "No help available." << endl;
    }
    The if statement will not execute.

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    i believe it is because you cannot do cmd=="help", not sure though.

    edit:: Infinate loop!!!

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    5
    Then what can you do?

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    sorry, edited my post after you posted.

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    5
    no problem, I see it, strcmp. thanks.

  6. #6
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    you're welcome.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple cin question
    By verbity in forum C++ Programming
    Replies: 25
    Last Post: 05-09-2007, 03:02 PM
  2. CIN Input count question?
    By kamran in forum C++ Programming
    Replies: 5
    Last Post: 10-24-2006, 04:06 PM
  3. Beginner Question about cout and cin
    By Dillius in forum C++ Programming
    Replies: 22
    Last Post: 04-06-2003, 11:17 AM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM
  5. cin Help...Sort of a noob Question?
    By Krak in forum C++ Programming
    Replies: 9
    Last Post: 01-26-2003, 12:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21