-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathPak.c
50 lines (38 loc) · 917 Bytes
/
Pak.c
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
#include <stdio.h>
#include <stdlib.h>
#define maxL 255
typedef struct{
int m;
char arr[maxL];
float a;} x;
int main(int argc, const char * argv[]){
FILE *file;
x * y = malloc(sizeof(x));
if (argc != 2)
{
printf("Where args? I need Args!\n");
return 0;
}
if ((file = fopen(argv[1], "r+b"))== NULL)
{
printf("No file\n");
return 0;
}
/*if ((file = fopen("Users/Àíòîí/Desktop/data.DAT", "r+b")== NULL)
{
printf("No file\n");
return 0;
}*/
int i=0;
while (!feof(file))
{
fread(y, sizeof(x), 1, file);
printf("%d %s %f\n", y -> m, y -> arr, y -> a);
i++;
}
fseek(file, 0, SEEK_END);
printf("Elements count: %d\n", i-1 );
printf("File size: %ld bytes", ftell(file));
fclose(file);
return 0;
}