例題:請補充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));
}
輸出運行視窗如下:

越努力越幸運!
加油,奧力給!!!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/249468.html
標籤:其他
