一、
#include <stdio.h>
int main()
{
char ch;
printf("Press a key and then press Enter");
scanf("%c",&ch);
ch=ch-32;
printf("%c",ch);
return 0;
}
二、
#include <stdio.h>
int main()
{
char ch;
printf("Press a key and then press Enter");
ch=getchar();
ch=ch-32;
printf("%c\n",ch);
return 0;
}
本文介绍了使用C语言实现字符大小写转换的两种方法:一种是通过scanf接收字符后进行转换,另一种是直接使用getchar函数读取字符并转换。这两种方法均通过将ASCII码减去32来实现大写到小写的转换。
391

被折叠的 条评论
为什么被折叠?



