将每一行字符中的每个单词的第一个字母改写成大写
发布网友
发布时间:2023-01-21 06:30
我来回答
共2个回答
热心网友
时间:2023-10-15 22:55
#include <stdio.h>
#include <stdlib.h>
int main() {
char s[8192],*p;
char *filename = "F:\\VC\\example.txt";
int i,ch,len;
FILE *fp;
fp = fopen(filename,"rt");
if(fp == NULL) {
printf("can't Open %s\n",filename);
exit(1);
}
i = 0;
while((ch = fgetc(fp)) != EOF) {
s[i] = ch;
i++;
}
s[i] = '\0';
len = i;
fclose(fp);
p = s;
while(*p) putchar(*p++);
printf("\n\n");
if((s[0] >= 'a') && (s[0] <= 'z')) s[0] -= ('a' - 'A');
i = 1;
while(s[i]) {
while((s[i]) && (s[i] != '.') && (s[i] != '\n')) i++;
if(s[i]) {
while(((s[i] < 'a') || (s[i] > 'z')) && (s[i])) i++;
if(s[i]) s[i] -= ('a' - 'A');
}
i++;
}
p = s;
while(*p) putchar(*p++);
printf("\n\n");
return 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.
热心网友
时间:2023-10-15 22:56
Ruby