例题:请补充fun函数,该函数的功能是将字符串str中的小写字母都改为对应的大写字母,其它字符不变。
例如:若输入”Welcome!”,程序输出结果是”WELCOME!”。
请勿改动主函数main与其它函数中的任何内容,仅在fun函数的横线上填写所需的若干表达式或语句。
代码如下:
#include<stdio.h>
#include<string.h>
#include<conio.h>
char*fun(char str[])
{
int j;
for(j=0;str[j];j++)
{
if((str[j]>='a')&&(str[j]<='z'))
str[j]-=32;
}
return(str);
}
main()
{
char str[100];
printf("\nplease enter a string:");
gets(str);
printf("\nThe result string is:\n%s",fun(str));
}
输出运行窗口如下:
越努力越幸运!
加油,奥力给!!!