Thread: Bitwise operator test - It keeps skipping past a certain point

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    4

    Question Bitwise operator test - It keeps skipping past a certain point

    Hello everyone, I'm currently reading "C++ Weekend Crash Course" by Stephen R. Davis. This is the first book I've read about C++. I'm still learining the basics. Anyways, In the chapter about "Logical Operations" there is a section focusing on "working with binary numbers", "performing bitwise operations", and "creating logical assignment statements". The book provides code for a "bitwise operator test". Here's the part that doesnt seem to work for me.

    Code:
    // input the first argument
        int nArg1;
        cout << "Enter arg1 as a four-digit hexadecimal: ";
        cin >> nArg1;
        
    //***Right here***    
        int nArg2;
        cout << "Enter arg2: ";
        cin >> nArg2;
        
        cout << "nArg1 & nArg2 =0x"
                  << (nArg1 & nArg2) << "\n";
                  
        cout << "nArg1 | nArg2 = 0x"
                  << (nArg1 | nArg2) << "\n";
                  
        cout << "nArg1 ^ nArg2 = 0x"
                  << (nArg1 ^ nArg2) << "\n";

    Everytime I run the program it works fine until it gets to the second argument. It skips right past the whole part of the code begining at "int nArg2; cout << "Enter arg2: "; cin >> nArg2;"
    and goes right into the next lines of code. Everything looks right to me. I've played around with programs that were more complex then this one and have gotten them working correctly. Any help would be greatly appreciated. I'm using Dev-C++.

    Oh and another thing, when I run my compiled programs soon as it gets to the end of the program the DOS prompt closes not giving me enough time to read my programs usally. Anyone know how I can remedy this? I've searched around through Dev-C++ looking for an option that would allow me to keep the programs open even after there finished but couldnt find anything. Thanks.
    Last edited by euphoric; 10-30-2002 at 02:38 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. observing whether a point is in a triangle???
    By hebele in forum C++ Programming
    Replies: 1
    Last Post: 05-19-2003, 03:38 PM
  2. fixed point / floating point
    By confuted in forum Game Programming
    Replies: 4
    Last Post: 08-13-2002, 01:25 PM
  3. point lies in circle?
    By cozman in forum Game Programming
    Replies: 3
    Last Post: 12-20-2001, 04:39 PM
  4. more with my 1st structure program
    By sballew in forum C Programming
    Replies: 42
    Last Post: 10-22-2001, 08:03 PM