将每一行字符中的每个单词的第一个字母改写成大写

1个回答

  • #include

    #include

    int main() {

    x05char s[8192],*p;

    x05char *filename = "F:\VC\example.txt";

    x05int i,ch,len;

    x05FILE *fp;

    x05fp = fopen(filename,"rt");

    x05if(fp == NULL) {

    x05x05printf("can't Open %sn",filename);

    x05x05exit(1);

    x05}

    x05i = 0;

    x05while((ch = fgetc(fp)) != EOF) {

    x05x05s[i] = ch;

    x05x05i++;

    x05}

    x05s[i] = ' ';

    x05len = i;

    x05fclose(fp);

    x05p = s;

    x05while(*p) putchar(*p++);

    x05printf("nn");

    x05if((s[0] >= 'a') && (s[0] 'z')) && (s[i])) i++;

    x05x05x05if(s[i]) s[i] -= ('a' - 'A');

    x05x05}

    x05x05i++;

    x05}

    x05p = s;

    x05while(*p) putchar(*p++);

    x05printf("nn");

    x05return 0;

    }

    example.txt

    in Europe,where people seem to improve their trains as fast as wei in the United States retire ours,we have living proof that railroads can compete with,and often outstrip,airlines and cars."if the distance is seven hundred miles or more,people in Europe might prefer to fly,"says an offical of the French National Railroads,"but when you get down to four or five hundred miles the train is convenient,"In France ,a businessman says to his secretary,"what's the next train to Lyons?"--not the next plane.taking the train is a way of life.as the fleet of Europe trains continues to cat the time between major cities in the bid to hit the magic 125 miles per hour mark,airlines are halting of diminishing short -- haul service and concertraining on the longer runs.

    转换后的example.txt

    In Europe,where people seem to improve their trains as fast as wei in the United States retire ours,we have living proof that railroads can compete with,and often outstrip,airlines and cars."If the distance is seven hundred miles or more,people in Europe might prefer to fly,"says an offical of the French National Railroads,"but when you get down to four or five hundred miles the train is convenient,"In France ,a businessman says to his secretary,"what's the next train to Lyons?"--not the next plane.Taking the train is a way of life.As the fleet of Europe trains continues to cat the time between major cities in the bid to hit the magic 125 miles per hour mark,airlines are halting of diminishing short -- haul service and concertraining on the longer runs.