C语言 降一点英文句子的首字母变为大写 有错误 希望改改

2025-04-18 19:25:51
推荐回答(3个)
回答1:

#include 
#include 
int main() {
int i;
char s[101] = {'\0'}; 
while(gets(s)) {
i = 0;
while(!isalpha(s[i]) && s[i]) ++i; // 先处理首字符 
if(islower(s[i])) s[i] = toupper(s[i]);
while(s[i]) {
if(s[i] == '.') { // .后面的字符应该改为大写 
while(!isalpha(s[i]) && s[i]) ++i;
if(islower(s[i])) s[i] = toupper(s[i]);
}
++i;
}
puts(s);
fflush(stdin);
}
return 0;
}

回答2:

没有发现有错误,就是用gets会有warning

回答3:

有什么错误你不说出来我们当测试给你测啊?????