求助达人,如何将单词的首个小写字母变成大写,急急急

来源:百度知道 编辑:UC知道 时间:2024/05/30 09:02:02
求助达人,如何将单词的首个小写字母变成大写,如this is a book变成This Is A Book,中间有空格隔开。
用C语言怎么写,请大侠们支招!我要的是C语言源代码啊,可以调用函数,能全部写出来吗?请加点注释,我是新手。

C代码如下:
#include "stdio.h"
#define N 50
main()
{
int isFirst=1;//tag of thefirst Char in a word
int i=0;
char str[N]={'\0'};
printf("input a sentense(input # to the end.)\n");
while(1)//input a sentence
{
scanf("%c",&str[i]);
if (str[i]=='#')
break;
i++;
}
str[i]='\0';
i=0;
while(str[i])
{
if (str[i]!=' '&&isFirst==1&&str[i]<='z'&&str[i]>='a')
{
str[i]=str[i]-32;
isFirst=0;
}
if (str[i]==' ')
{
isFirst=1;
}
printf("%c",str[i++]);
}
getchar();
}

你看看可否这样。
include <stdio.h>
int main()
{
char *p;
scanf("%s&qu