where is the problem?
Can you read a string from a file? if not, see http://www.cplusplus.com/doc/tutorial/files/
Then you have to iterate through the string and check whether it is in range form 'A' to 'Z'. If so subtract ('A'-'a') from it (there is a function to do that - http://www.cplusplus.com/reference/clibrary/cctype/tolower/ but I think a manual way is better when learning stuff). Also, if the letter is neither in range form 'A' to 'Z' nor from 'a' to 'z' set it to '!'
bitwise operators case change at the system level, however I suppose additional code should be written for special or null characters
To uppercase:
The value 223 used in the AND statement is the decimal representation of 1101 1111. The operation will leave all bits unchanged except for the 6th bit, which will be set to 0; lowercase letters are the same as the uppercase except the lowercase ones are greater than uppercase by a value of 32 so to change from lowercase to uppercase, just turn the 6th bit off.
// Uppercase letters using bitwise AND '&'
#include <iostream>
usingnamespace std;
int main()
{
char ch;
for (int i=0;i<10;i++) {
ch = 'a' + i;
cout << ch;
// This statement turns off the 6th bit
ch = ch & 223; // ch is now uppercase
cout << ch;
}
cout << "\n";
return 0;
}
.
aAbBcCdDeEfFgGhHiIjJ
To lowercase:
the bitwise OR , as the reverse of AND can be used to turn bits on, any bits that are set to 1 in either operand will cause that bit turn on, the value used in the arguement would be 32(this turns the 6th bit on)