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

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    4

    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:

    Code:
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    int main(int argc, char *argv[])
    {
       
       //Variables
        
        char charName[21];
        char race[6];
      
       //Intro
       
         cout << "BLAH";
       
       //Character Information
          
            //Name
       cout << "Enter a Name:\n" ;
       cin.get(charName,21);
       cin.ignore(100,'\n');
       cout << "Good Morrow, "  << charName << '\n';
             
             //Race
       cout << "Race: \n";
       cin >> race;
        
       while(strcmp(race, "human")!=0)
        {      
            cout << "YOU FAIL! \n...Race: \n";       
        }   
       cout << "Name:  " <<  charName <<  "\n" << "Race:  "  <<  race << "\n";
            //Class
            //Gender
           system("PAUSE");
           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
    -Scott

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    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"...".

    [edit]Also,
    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
    Location
    England
    Posts
    1,688
    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 Cprogramming.com
    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 Cprogramming.com
    Replies: 10
    Last Post: 04-29-2002, 12:30 AM
  5. Small app ideas
    By dirkduck in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 02-15-2002, 08:57 PM