关于小写字符转换成大写字符
#include <iostream.h>
#include <string.h>
void main()
{
char test[]= "Hello! ";
int size = strlen(test);
for(int i = 0; i < size; i++)
{
if(test[i]> = 'a ' && test[i] <= 'z ')
{
test[i] = test[i] | 11011111;
}
}
cout < < "test = " < <test < <endl;
}
按照我的ASCII码来分析的话,小写字母在二进制里在位5上是1,而大写字母是0,于是我想通过位的或运算把该位改成0实现小写转换成大写,但是以上程序有问题,还请帮忙看看~
[解决办法]
test[i] = test[i] | 11011111;
楼主这个11011111是当二进制在用吗?编译器可是当十进制处理的