大写转成小写字母

  • A = 65

a = 97
相差32;依次做差即可

  • A |= 32 = a

    将字符串流 改成字符串 istringstream

  • include

    1. string str=" i an a boy ";
    2. istringstream istring(str);
    3. string s;
    4. while(istring >> s)
    5. cout << s << endl;
    6. 输出是:
    7. i
    8. am
    9. a
    10. boy

    大小写转化 位运算

    | 大写变小写、小写变大写(全变) | A(a) ^= 32 a(A) | | | —- | —- | —- | | 大写变小写、小写不变 | A(a) |= 32 a(a) | | | 小写变大写、大写不变 | A(a) &= -33 A(A) | |