// & 与,将指定位置设置为0 | 或,将指定位置设置为1 //注: 只针对纯字母的情况 #include <stdio.h> #include <string> int main() { char str[6] = "xxing"; std::string str1 = "INGXX"; for(int i = 0; i < 5; i++) { str[i] &= 0xdf;// 转大写 1101 1111 str1[i] |= 0x20;// 转小写 0010 0000 } printf("xxing:%s/nINGXX:%s/n", str, str1.c_str()); return 0; }