填空题
给定程序MODI1.C中函数fun的功能是:将s所指字符串中的字母转换为按字母顺序的后续字母(但Z转换为A,z转换为a),其他字符不变。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
文件MODI1.C内容如下:
#include<stdio.h>
#include<ctype.h>
void fun(char *s)
/**********found**********/
while(*s!=’@’)
if(*s>=’A’&&*s<=’Z’||*s>=’a’&&*s<=’z’)
if(*s==’Z’) *s=’A’;
else if(*s==’z’) *s=’a’;
else *s+=1:
/**********found**********/
(*s)++;
void main( )
char s[80];
printf("\n Enter a string with length<80. :\n\n");
gets(s);
printf("\n The string: \n\n");
puts(s);
fun(s);
printf("\n\n Tile Cords: \n\n");
puts(s);
【参考答案】
第1处:将“while(*s!=’@’)”改为“while(*s!=’\0’)”。
第2处:将“(*s)++;......
(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)