I am pretty new to c++ and have had a pretty easy time with it till i got to bitwise logic operations. I tried an example program out of a book I have and can't get it to work.
The code is:
#include <stdio.h>
#include <iostream.h>
int main(int nArg, char* nArgs[ ])
{
cout.setf ( ios::hex);
int nArg1;
cout << "Enter arg1 as a four-digit hexadecimal;";
cin >> nArg1;
int nArg2;
cout << "Enter arg2:";
int nArg2;
cout << "Enter arg2:";
cin >> nArg2;
cout << "nArg1 & nArg2 = 0x"
<< (nArg1 & nArg2) << "\n";
return 0;
}
when i put in a hex number like 0x1234 it will not let me put in the second argument and just gives me an answer.
could you please help?
thank you
The code is:
#include <stdio.h>
#include <iostream.h>
int main(int nArg, char* nArgs[ ])
{
cout.setf ( ios::hex);
int nArg1;
cout << "Enter arg1 as a four-digit hexadecimal;";
cin >> nArg1;
int nArg2;
cout << "Enter arg2:";
int nArg2;
cout << "Enter arg2:";
cin >> nArg2;
cout << "nArg1 & nArg2 = 0x"
<< (nArg1 & nArg2) << "\n";
return 0;
}
when i put in a hex number like 0x1234 it will not let me put in the second argument and just gives me an answer.
could you please help?
thank you