Thread: What is wrong with this single if statement?

  1. #1
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153

    What is wrong with this single if statement?

    I have been staring at this line of code for an hour, I just can't see anything wrong with it? Compiler says 31: expected a , before or.

    Code:
    if ( (tempoption->style == 1) or (tempoption->style == 2) or (tempoption->style == 3) or (tempoption->style == 4) or (tempoption->style == 5) )
    {
    // DO STUFF;
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    25,236
    If you want to use or instead of || then you should #include <iso646.h>. For the most part, I don't see the point.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153
    As always, you rock. But 'and' is OK? Or should I use &. ?.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    25,236
    Quote Originally Posted by javaeyes
    But 'and' is OK? Or should I use &.
    Same thing as or. Also, the normal version of and is &&. The alternative version of & is bitand. My take is that unless you have some very special reasons to use the stuff in <iso646.h>, don't.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153
    Thanks Laser.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what's wrong while statement
    By gamer in forum C++ Programming
    Replies: 3
    Last Post: 05-06-2004, 03:18 AM
  2. Combine code into a Single statement
    By srlien24 in forum C Programming
    Replies: 2
    Last Post: 12-12-2003, 11:47 AM
  3. What's wrong with this IF-statement?
    By kinghajj in forum C++ Programming
    Replies: 6
    Last Post: 11-12-2003, 05:49 AM
  4. What is wrong with this statement???
    By j0hnb in forum C Programming
    Replies: 5
    Last Post: 04-22-2003, 07:03 PM
  5. Something wrong with this if statement?
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 04-30-2002, 05:19 PM