题目:输入一行字符串,把其中的小写字母改成大写字符,并输出该字符串。
#include <stdio.h>
int main()
{char str[80];
int i;
char low_to_upper(char c);//函数声明
printf("Enter a string:");
gets(str);
for (i=0;str[i];i++)
str[i]=low_to_upper(str[i]);//自定义函数调用
puts(str);
return 0;
}
char low_to_upper(char c)//函数定义
{if (c>='a'&&c<='z')
return c=c-32;//A的ASCII码是65,a的ASCII码是97
return c;
}