编写函数(upfst),要求读入一个英文文本行,将其中每个单词的第一个字母改成大写,然后输出此文本行(这里"单词"是指由空格隔开的字符串)
例如,若输入: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>
/**********Program**********/
void upfst(char* p)
{
int m = 0;
for (; p != 0; p++)
if (m != 0)
{
if (*p == ' ')
m = 0;
}
else if (*p != ' ')
m = 1, * p = *p - 32;
}
/**********Program**********/
int main()
{
char chrstr[81];
printf("AnPlease enter an English text line: \n");
gets(chrstr);
printf("\nBefore changing: \n %s", chrstr);
upfst(chrstr);
printf("\nAfter changing: An %sin ", chrstr);
}