/*----------------------------------------------------------------------
题目: 编写程序,要求读入一个英文文本行,将其中每个单词的第一个字母改成大写,然后输出此文本行(这里"单词"是指由空格隔开的字符串)。
例如,若输入:I am a student to take the examination.,
则应输出:I Am A Student To Take The Examination.。
-----------------------------------------------------------------------*/
#include <stdlib.h>
#include<ctype.h>
#include<string.h>
#include<stdio.h>
void upfst(char *p)
{
int k=0;
for(;*p;p++)
if(k)
{
if(*p==' ')
k=0;
}
else if(*p!= ' ')
{
/**********Program**********/
k = 1;
*p = toupper(*p);
/********** End **********/
}
}
int main()
{
char chrstr[81];
printf("\nPlease enter an English text line:\n");
gets(chrstr);
printf("\nBefore changing:\n %s",chrstr);
upfst(chrstr);
printf("\nAfter changing:\n %s\n ",chrstr);
}