C语言程序中,如何区分字符是数字还是字母?
char ch;
ch=getchar();
if(ch>='0'&&ch<='9')
printf("数字");
if(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z')
printf("字母");
2.
#include <stdio.h>
int main(){
char char1 = 184;
char char2 = 246;
printf("Print1:\n");
printf("%c",char1);
printf("\n");
printf("%c", char2);
printf("\n Print2:\n %c%c\n",char1, char2);
printf(" Print3:\n ");
printf("%c",char1);
printf("%c",char2);
return 0;
}
让我们来看一下结果:
所以我们还可以这样玩:
#include <stdio.h>
#include <unistd.h>//VC退散
int main(){
char hexchar[19] = {0xc1,0xd6,0xb2,0xd3,0xb1,0xf3,0x2c,0x20,0x49,0x20,0x4c,0x6f,,0x76,0x65,0x20,0x59,0x6f,0x75,0x21},i;
for(i=0;i<19;i++){
printf("%c",hexchar[i]);
_sleep(300);
}
return 0;
}