Thread: "n00b" while statement problem

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    19

    "n00b" while statement problem

    Hi am trying to write a statement that checks a string using a while statment.

    Basically while varA is not equal to "a" or "b" or "c" say "not a, b or c. try again"

    Here is my first go.

    Code:
    while (thing.me != "A" || "B" || "C") {
    		cout << "Not A B or C" << endl << "try it again" << endl;
    		cin >> thing.me;
    	};
    This does not work. If I take out the B and C bit then it works. If not it always says that it isn't A B or C. What am I doing wrong?

    Thanks

    Ironfistchamp

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    We wish a compiler was that smart.

    while (thing.me != "A" && thing.me != "B" && thing.me != "C")

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    19
    Hehe thanks very much. I am sure you will be hearing a lot more from me with more obvious questions .

    Thanks again

    Ironfistchamp

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Switch statement problem
    By jalex39 in forum C Programming
    Replies: 6
    Last Post: 03-08-2008, 04:05 PM
  2. having problem with string statement during a loop!
    By Hp7130p in forum C++ Programming
    Replies: 5
    Last Post: 04-21-2005, 09:40 AM
  3. If statement re-do problem
    By RoD in forum Windows Programming
    Replies: 5
    Last Post: 09-11-2002, 04:46 PM
  4. Major Problem
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 02-19-2002, 01:06 PM