1#include <stdio.h>
 2#include <string.h>
 3
 4#include "struct.h"
 5
 6int main(void) {
 7    printf("Write struct\n");
 8
 9    Character ch;
10
11    strcpy(ch.name, "John Doe");
12    ch.health = 30;
13    ch.damage = 5.9;
14
15    FILE *file = fopen("character.dat", "wb");
16    if (file == NULL) {
17        perror("Error opening file");
18        return 1;
19    }
20
21    fwrite(&ch, sizeof(Character), 1, file);
22    fclose(file);
23
24    return 0;
25}