I came to a point in my C++ book where I have to start using bitwise operators, such as &, ^, and |. I have a hard time grasping the concept of exactly how do I manipulate bits, the following example supposedly "turns off the 6th bit", therefore inverting the case of the character.
Here is my code:
#include <iostream>
using namespace std;
int main()
{
string line;
char ch;
for(int i = 0; i < 10; i++)
{
ch = 'a' + i;
cout << ch;
ch = ch & 223;
cout << ch << " ";
}
cout << "\n";
getline(cin,line);
cin.get();
return 0;
}
Now, in the line ch = ch & 223;
it basically says the char ch equals to ...? I don't understand how the ch & 223
affects the case of the character. I DO know that uppercase and lowercase characters are 32 bits apart, right? And I DO see that 223 is exactly 32 less than 255, but I don't really know how it all works.
Please help, and thank you :]