Reading/Writing structs to files (aka Serialization)

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Hey, that is the most in-depth explanation for serialization and struct files i have found on Youtube and Stack Overflow. I've been fighting with my code for the past 4 days because i was trying to save a huge dynamic 2d struct to a bin file, but didn't know why the reading from file was failing. I used the ideas about format specifying and coma separation and did the job. Really glad i found your channel. + You give in-depth info about all other subjects, unlike all the other 10 000 000 videos showing a 15-minute fprintf and fscanf. Keep up the good work <3

kalinmarinov
Автор

Your teaching is awesome and I'm very grateful for everything I've learned (and will learn) in this excellent channel. Keep it up!

jakobfredriksson
Автор

Honestly, you have the best tutorials about the C programming language, absolutely the best. Congratulations and thank you very much!

gammyhorse
Автор

I need to use serialization/deserialization for my project and you explained it in a way that makes it easy. Thank you

sgyniguez
Автор

I have no words to describe how much you have helped me! I am so grateful that this amazing content is open and free. Thank you so much!

melanymaciasmoran
Автор

If one is not going to transfer data between different architectures then one can write the binary data directly from memory to the file and back. The problem with doing it on different architectures is that the byte order of big numbers might differ. One also has to be careful about alignment which might differ.

mdperpe
Автор

A bit late, but I have done quite a bit of googling on serialization / deserialization in C - was not a lot out there, and this was simple, to the point, and matches my use case almost exactly. (I want a more TOML/systemd unit style format, but that is an easy change to make). Subscribed, and will def be watching more videos.

etherweb
Автор

I came here to understand "JSON Serialization", and I really got the whole picture. Thanks, man :)

mohamedhany
Автор

i'm 30 seconds into the video and i already know this guy is about to spit some facts

eddiekiller
Автор

Actually this channel is amazing, so glad I found it.

finiavanamandresy
Автор

This is great stuff, would love to see it in C++ as well.

weelaiyang
Автор

Such an underrated channel. I would like to tell you that you make awesome content and I really appreciate your efforts!

husseinyoussef
Автор

The Vincent Willem van Gogh of programming.

chriscruz
Автор

Thank you so much. You explained it really well, but I have a question: What if I only want to save the age and gender in variables, but not the name? I tried to use "{\n\t\"name\": \"[^\"]+\", \n\t\"age\": %d, \n\t\"gender\": \"%c\"\n}" as PERSON_FORMAT_IN and fscanf_s(file, PERSON_FORMAT_IN, &p2.age, &p2.gender) function, but it doesn't work. I think it has something to do with the "+" symbol. I'm not really sure of that. How would I solve it? Thanks in advance.

capc
Автор

Thank you very much! Exactly what I needed. :)

zhulikkulik
Автор

Just in time when decided to dig C and C++ again then saw this

Thank you, 👍🏽❤️👍🏽

_prothegee
Автор

Thank you for the video! It was really helpful for me!

hanaksi
Автор

Very nice channel. Is there a reason to use a comma rather than spaces or tabs? Just wondering if it makes scanf easier

munawarcheema
Автор

Thanks again for a great video from a C learner for about a year.

I ended up using binary files and got rid of ascii 10 and 13 chars in my files.

Is this code a "problem" or it just a matter of style, because I want to "do stuff" immediately:

if (fp != NULL) {
do stuff
} else {
oh oh...

And because of learning C, I am not using the string.h either, but do all editing mostly by pointers and using a debugger a lot.

grimvian
Автор

Thanks! What JSON library do you recommend for C? Could you make a video of that too?

jabuci