-
Notifications
You must be signed in to change notification settings - Fork 13
/
Eldarov.c
42 lines (38 loc) · 1.07 KB
/
Eldarov.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
#include <stdio.h>
struct packet {
int x;
char string[255];
float floatingpointnumber;
};
int main(int argc, char** argv)
{
char path[255];
FILE *f;
struct packet packet1;
if (argc != 2) /*(! (f = fopen("data.dat", "rb")))*/
{
printf("Enter the path to file (data.dat): ");
scanf("%s",path);
if (!(f = fopen(path, "rb")))
{
printf("File don't exist\n");
return 0;
}
} else
if (!(f = fopen(argv[1], "rb")))
{
printf("File don't exist\n");
return 0;
}
int i = 0;
printf("\n Num. of Str: \t String:\t Floating point number: \n");
while(fread(&packet1, sizeof(struct packet), 1, f))
{
printf(" %d | %s | %f |\n", packet1.x, packet1.string, packet1.floatingpointnumber);
i++;
}
printf("-------------------------------------------------------------------------");
printf("\n\t\t\t Filesize: %lu\n", i * sizeof(struct packet));
fclose(f);
return 1;
}