include stdlib include stdio int main int argc char argv int char fnam

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
int k=1;
char c, fname[25];
FILE *f, *buf;
if(argc==1){
printf("‚¢¥¤¨â¥ ¨¬ï ä ©«  ¤«ï ®¡à ¡®âª¨: ");
scanf("%s", fname);
}
if(argc==2){
strcpy(fname, argv[1]);
}
if((f=fopen(fname, "r"))==NULL) {
printf("Žè¨¡ª  ¯à¨ ®âªàë⨨ ä ©« !\n");
system("pause");
return 0;
}
if((buf=fopen("buf.txt", "w"))==NULL) {
printf("Žè¨¡ª  ¯à¨ ¯à¨ ᮧ¤ ­¨¨ ä ©« !\n");
system("pause");
return 0;
}
while(fscanf(f, "%c", &c)!=EOF){
if (k){
if((c>=65 && c<=90)||(c>=-64 &&c<=-33))
k=0;
if((c>=97 && c<=122)||(c>=-32 && c<=-1)){
c-=32;
k=0;
}
}
if (c=='.' || c=='?' || c=='!' ) k++;
fprintf(buf, "%c", c);
}
fclose(f);
fclose (buf);
remove(fname);
rename("buf.txt",fname);
return 0;
}