#include <stdio.h>
#include <string.h>
int ToUpper(int c);
int main()
{
char str[81];
int i=0;
puts("input a string");
while (strcmp(gets(str),"quit"))
/*
while循环里只要条件不为0,就可以继续循环
一般形式:strcmp(字符串1,字符串2)说明:
当s1<s2时,返回值<0
当s1==s2时,返回值=0
当s1>s2时,返回值>0
*/
{
while (str[i]!='\0')
{
str[i]=ToUpper(str[i]);
i++;
}
printf("%s\n",str);
}
}
int ToUpper(int c)
{
if (c>='a'&&c<='z')
{
return c-('a'-'A');
}
else
{
return c;
}
}
小写字母转大写字母
最新推荐文章于 2024-07-22 06:30:00 发布