编写程序,读入一个英文文本行,将其中每个单词的第一个字母改成大写,然后输出此文本行(这里的“单词”是指由空格隔开的字符串)。编写主函数,输入输出在主函数中进行。
#include<stdio.h>
int fun(char s[])
{
int n = 1;
while (s[n] != '\0')
{
s[0] -= 32;
if (s[n] == ' ')
if (s[n + 1] >= 'a' && s[n + 1] <= 'z')
s[n + 1] -= 32;
n++;
}
return 0;
}
int main()
{
char s[100];
int b;
gets_s(s);
fun(s);
puts(s);
return 0;
}