blob: b67974fb5e5c3593e098f9464f5f5116ef947991 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <stdio.h>
#include "struct.h"
int main(void) {
printf("Read struct\n");
Character ch;
FILE* file = fopen("character.dat", "rb");
if (file == NULL) {
perror("Error opening file");
return 1;
}
fread(&ch, sizeof(Character), 1, file);
fclose(file);
printf("Name: %s\n", ch.name);
printf("Health: %d\n", ch.health);
printf("Damage: %.1f\n", ch.damage);
return 0;
}
|