C大小写转换问题

#include <stdio.h>

#include <stdlib.h>

#include <ctype.h>



int main()

{

    printf("Hello world!\n");

    char ch[100]="hEll,O!@#$!@#$!@St4465456ri45656ngIKLSDJFLsdkjfsdiwerjdskfjsd";

    char *pc=ch;

    printf("处理前:%s\n",ch);

    for(;*pc!='\0';pc++){

        if(isalpha(*pc)){

            // ascii: 'a': 61H; 'A':41H

            //*pc |= 0x20;      //按位或,转为小写

            *pc &= (~0x20);     //按位与,转为大写

        }

    }

    printf("处理后:%s\n",ch);

    return 0;

}

  

你可能感兴趣的:(大小写)