将大写字母转化成小写字母输出
**方法一:**前提:(输入以’.'结尾的一串字符)
使用scanf和printf函数。
#include <stdio.h>
int main()
{
char c;
scanf("%c",&c);
while (c!= '.') {
if (c>='A' && c<='Z') {
printf("%c",c-'A'+'a');
}
else{
printf("%c",c);
}
scanf("%c",&c);
}
return 0;
}
方法二::使用putchar函数,getchar函数
#include <stdio.h>
int main(){
char c;
printf("Input an uppercase letter:\n");
c = getchar();//用getchar输入一个字符
putchar(c + 32);//由于在ASCII中大写字母与小写字母差值32
return 0;
}