include stdio include stdlib include string void toup FILE int main in

 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void toup(FILE *);
int main(int argc, char *argv[])
{
FILE *f;
char filename[100], c;
int n,k=0;
if (argc == 1)
{
puts("Input filename");
gets(filename);
}
else strcpy(filename, argv[1]);
if ((f = fopen(filename, "r+")) == NULL)
{
puts("Error");
system("pause");
return 1;
}
fseek(f, 0, SEEK_END);
n = ftell(f)/sizeof(char);
fseek(f, 0, SEEK_SET);
toup(f);
while (--n)
{
fread(&c, sizeof(char), 1, f);
if (c == '.' || c == '?' || c == '!')
{
fseek(f, 0, SEEK_CUR);
toup(f);
fseek(f, 0, SEEK_CUR);
n--;
}
}
fclose(f);
system("pause");
return 0;
}
void toup(FILE *f)
{
char c;
fread(&c, sizeof(char), 1, f);
if (c >= 'a' && c <= 'z' || c >= 'à' && c <= 'ÿ')
{
c -= 32;
fseek(f, -1, SEEK_CUR);
fwrite(&c, sizeof(char), 1, f);
fseek(f, 0, SEEK_CUR);
}
else if(c == ' ')
{
fseek(f, 0, SEEK_CUR);
fread(&c, sizeof(char), 1, f);
}
else if (c == '\n')
toup(f);
}