Need help checking variables

This is a discussion on Need help checking variables within the C++ Programming forums, part of the General Programming Boards category; I am trying to find a way to see if 5 or so variables all contain the same number in ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    3

    Need help checking variables

    I am trying to find a way to see if 5 or so variables all contain the same number in an if statement. Something to the effect of this.

    Code:
    	if(getrow21() == getrow22() == getrow23() == getrow24() == getrow25())

  2. #2
    Registered User
    Join Date
    Feb 2006
    Posts
    3
    Nevermind figured it out.

  3. #3
    Registered User wildex999's Avatar
    Join Date
    Feb 2006
    Posts
    15
    Can you please post how you did it? May help others with same question, or who just wan't to learn.

  4. #4
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    the most obvious (but most tedious) way:

    Code:
    if ( var1 == var2 ) &&
       ( var1 == var3 ) &&
       ( var1 == var4 ) &&
       ( var1 == var5 )
          { /*Do Stuff */ }

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    the most obvious (but most tedious) way

    Code:
    if ( var1 == var2 ) &&
       ( var1 == var3 ) &&
       ( var1 == var4 ) &&
       ( var1 == var5 )
          { /*Do Stuff */ }
    That won't even compile.

  6. #6
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    Quote Originally Posted by 7stud
    That won't even compile.
    He forgot the outer parenthesis

  7. #7
    Registered User
    Join Date
    Feb 2006
    Posts
    3
    I pretty much did what he said to do. Might end up changing how it keeps values later on and work on something better, but that works for now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Father and Son Variables
    By khdani in forum Linux Programming
    Replies: 3
    Last Post: 11-28-2008, 06:42 PM
  2. Replies: 15
    Last Post: 09-30-2008, 03:12 AM
  3. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 06:59 PM
  4. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 04:25 AM
  5. static variables
    By Luigi in forum C++ Programming
    Replies: 4
    Last Post: 04-24-2003, 08:13 PM

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