From 29cc82fdeb3a368e8b07a70b09b19effa5dde490 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Sat, 22 Jun 2024 19:59:47 +0200 Subject: New note: Read, write structs --- .../notes/2024-06-22-write-and-read-structs-to-files-in-c.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/content/notes/2024-06-22-write-and-read-structs-to-files-in-c.md b/content/notes/2024-06-22-write-and-read-structs-to-files-in-c.md index d5508e8..192bdfe 100644 --- a/content/notes/2024-06-22-write-and-read-structs-to-files-in-c.md +++ b/content/notes/2024-06-22-write-and-read-structs-to-files-in-c.md @@ -49,7 +49,17 @@ int main(void) { } ``` -And reading and serializing back to a struct. +If we check the contents of the `character.dat` file it should look like this. + +```txt +$ xxd character.dat +00000000: 4a6f 686e 2044 6f65 0000 0000 0000 0000 John Doe........ +00000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +00000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +00000030: 0000 0000 1e00 0000 cdcc bc40 ...........@ +``` + +Reading and serializing back to a struct. ```c // read.c -- cgit v1.2.3