#include <stdio.h>
int main(int argc, const char * argv[]) {
char ch;
printf("press a key and then press enter");
ch=getchar(); //getchar()是C语言函数库中专门用于输入字符的函数,它没有参数,函数的返回值就是从终端键盘中读入的字符,
ch=ch+32; //将大写字母转化为小写字母,小写字母的ascii码值比大写字母大32
putchar(ch); //putchar()函数是c语言标准库中专门用于输出字符的函数,注意:它输出的是字符,而不是字符串,字符是用单引号引起来的,而字符串使用双引号引起来的,printf("\n"中是字符串,因为是格式控制字符串
putchar('\n');
}
扩展:
(1)字符在计算机内存中用二进制保存它的ascii码值,并不保存字符本身。
(2)'a'是字符常量,a是标识符。
(3)若printf("%c %d\n",ch,ch),则先输出字符,再输出字符的ascii码值。