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