include stdio include stdlib include string include locale define 500

 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
68
69
70
71
72
73
74
75
76
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#define N 500
int main(int argc, char *argv[])
{
FILE *file, *file2 ;
int i=1, flag=0;
long int end; /* ïðèçíàê êîíöà ôàéëà */
char namefH[100]={} ;
char Vstr[N]; /* áóôåð */
char si;
/* ïðîâåðêà êîë-âà ïåðåäàííûõ ïàðàìåòðîâ */
if(argc==1)
{
printf(" ‚¢¥¤¨â¥ ¨¬ï ä ©«  ¤«ï ®¡à ¡®âª¨:\n");
scanf("%s", namefH);
}
if(argc==2)
{
strcpy(namefH,argv[1]);
}
file2=fopen("vremenno.txt","a+");
/* ïðîâåðêà îòêðûòèÿ ôàéëà */
if((file=fopen(namefH,"r"))== NULL)
{
printf(" ­¥ 㤠«®áì ®âªàëâì\n", namefH);
system("PAUSE");
return 1;
}
fseek(file , 0, SEEK_END );
end = ftell(file);
fseek(file , 0, SEEK_SET );
while( ftell(file)!=end )
{
si=fgetc(file);
if(si!='\n')
{
if(si==' ')
{
if(flag==0)
i++;
flag=1;
}
else
flag=0;
if(i%5!=0)
Vstr[i]=si;
}
else
{
if(flag==0)
i++;
flag=1;
Vstr[i]=si;
Vstr[++i]='\0';
fprintf(file2, "%s", Vstr);
i=0;
}
}
fclose(file2);
system("PAUSE");
return 0;
}