Thread: Im lost... any ideas? please help

  1. #1
    Registered User
    Join Date
    Nov 2006

    Question Im lost... any ideas? please help

    I am just starting C++ so i do not know very much how ever i hope to acomplish a fairly simple program to learn more about C++. Here is the problem:

    #include <cstdlib>
    #include <iostream>
    using namespace std;
    int main(int argc, char *argv[])
        char charName[21];
        char race[6];
         cout << "BLAH";
       //Character Information
       cout << "Enter a Name:\n" ;
       cout << "Good Morrow, "  << charName << '\n';
       cout << "Race: \n";
       cin >> race;
       while(strcmp(race, "human")!=0)
            cout << "YOU FAIL! \n...Race: \n";       
       cout << "Name:  " <<  charName <<  "\n" << "Race:  "  <<  race << "\n";
           return EXIT_SUCCESS;
    The While loop works for just "human", i would like it to work for "human" and "elf". I have tried to use the ( || ) but i could not get it to work. If you have any idea what i am doing wrong, what i have to do to make it work, or anything to improve anything else please reply. Thank you

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Quote Originally Posted by C++Noobie
    I have tried to use the ( || ) but i could not get it to work.
    Consider &&, because if you say it out loud it makes sense, "while the race is not "human" and the race is not "elf"...".

    FAQ > How do I... (Level 1) > Obtain a string from the user (C++)
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    hmmm looks very simular to the program you posted a little bit down the board titiled
    "help with if statements"

    Please only post the problem using one thread. People will answer you, there is no need to double post the same problem
    Double Helix STL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ideas, how do you get them? xD
    By Akkernight in forum A Brief History of
    Replies: 10
    Last Post: 01-22-2009, 03:53 AM
  2. Project ideas
    By steve1_rm in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2008, 05:34 AM
  3. cool ideas for a game
    By Shadow12345 in forum Game Programming
    Replies: 7
    Last Post: 05-18-2004, 08:37 PM
  4. idea's idea's idea's
    By mithrandir in forum A Brief History of
    Replies: 10
    Last Post: 04-29-2002, 12:30 AM
  5. Small app ideas
    By dirkduck in forum A Brief History of
    Replies: 4
    Last Post: 02-15-2002, 08:57 PM