Comment on [HELP] Converting JSON to Sqlite in C

<- View Parent
abhibeckert@lemmy.world ⁨1⁩ ⁨year⁩ ago

Well, Python is my friend now.

The Python read() function, which is basically the same as fread() also accepts a length parameter and 1024 is a sensible number to give it.

You can read the entire file in python but you probably shouldn’t do that. In the real world, your software will be given files larger than it can handle and it’s important to have logic in place to process the file incrementally instead of all at once. Honestly, it’s what makes this particular problem so challenging.

It’s definitely possible to write a C program that reads the entire file. You just won’t find many examples of that because it’s a bad idea.

You said you used an “AI to assist” but it failed? What were you using? I pasted it into ChatGPT 4 and it found eight problems - including the buffer issue.

source
Sort:hotnewtop