Or

This is a discussion on Or within the C++ Programming forums, part of the General Programming Boards category; i using borland c++ version 5.5, and when trying to do the or operator, which is denoted by ||, it ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    24

    Or

    i using borland c++ version 5.5, and when trying to do the or operator, which is denoted by ||, it says the symbol | is an illegal character.

    I'm presuming this to mean i don not have the correct header file (i think thats what they're called), but i could be wrong.

    Any ideas?
    Last edited by derek tims; 03-19-2006 at 04:19 PM.

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    >>Any ideas?

    Yes -- POST CODE.

  3. #3
    Registered User
    Join Date
    Mar 2006
    Posts
    24
    if i really need to post my code then of course, i will.............

    but, i'm not sure if it'll make the slightest difference a its fairly long. i would just like to be able to use the or operator.

    i have this line in the code:

    Code:
     if ( a > 0 || (a < 10 && b == 1) )
    
        {  code  
     
         }
    now when i have this line in, i got that | is an unrecognizable character.
    Last edited by derek tims; 03-19-2006 at 04:52 PM. Reason: inaccurate

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    is that line enclosed in an if statement? If not, then it makes no sense.
    Code:
    if( a > 0 || (a < 10 && b == 1) )
    {
    
      // do something when true
    }

  5. #5
    Registered User
    Join Date
    Mar 2006
    Posts
    24
    oops...... how silly. of course it is enclosed within an if statement. i will edit the post for more accuracy.

  6. #6
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Quote Originally Posted by derek tims
    oops...... how silly. of course it is enclosed within an if statement. i will edit the post for more accuracy.
    That is one of the dangers of not posting snippet of actual code -- just copy and paste that way you won't make typing mistakes. It does not good to see something that isn't in your real program.

  7. #7
    Registered User
    Join Date
    Mar 2006
    Posts
    24
    i think it may be my version i'm running. just downloaded a piece of source code that had the || in it, and it failed to compile.

    i'm running the free borland 5.5 version.

  8. #8
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,068
    Sent from my iPadŽ

  9. #9
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    Code:
    if(( a > 0) || (a < 10 && b == 1) )
    {
    
      // do something when true
    }
    Is your input language english?
    Copy the code from here and paste it into IDE.
    Last edited by siavoshkc; 03-19-2006 at 05:49 PM.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  10. #10
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,068
    Quote Originally Posted by siavoshkc
    Code:
    if(( a > 0) || (a < 10 && b == 1) )
    {
    
      // do something when true
    }
    Is your input language english?
    Copy the code from here and paste it into IDE.
    Not that I disagree that he should be copying his code rather than writing an example, what about the code you have in your post doesn't seem correct to you?
    Sent from my iPadŽ

  11. #11
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    to the OP - copy/paste this code and try to compile it. If it doesn't work, you might have your compiler setup incorrectly.
    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
        if ( true || false )
            cout << "Hello";
        cin.get();
    }

  12. #12
    Registered User
    Join Date
    Mar 2006
    Posts
    24
    i have figured it. i've been editing in a dos window previously, and the || won't work.

    opening it up in notepad, and trying that works just fine.

    glad that's sussed!! thanks for the advice.

Popular pages Recent additions subscribe to a feed

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