#include"stdio.h"
void main()
{
int i;
char str[100];
printf("请输入一个字符串:");
gets(str);
if(str[0]>=97&&str[0]<=122)
str[0]=str[0]-32;
for(i=1;str[i]!='\0';i++)
{if(str[i-1]==' '&&str[i]>=97&&str[i]<=122)
str[i]=str[i]-32;
}
puts(str);
}
希望我的回答会对您有所帮助!
#include
#define N 100
void main()
{
char a[N]={"what are you talking about?"};
int i;
for(i=0;iif(i>0&&a[i-1]==' ')a[i]-=32;
else if(i==0)a[i]-=32;
printf("%s",a);
}
//已测试,输出结果为What Are You Talking About?
//因为不知道具体句子是怎么样的,我就按字母都是小写来处理了