-4

I use python and javascript in my daily workflow. I am really excited about understanding c as I am drawn towards contributing to projects that are written in the language but even after weeks of learning I am not able to wrap my head around how certain things work in C

Like, right now I am trying to figure out how to store structured data to a file in c so that I can experiment with building small tools and get a better grasp on the language. but so far I am just able to find the basic file read/write examples and coming from a scripting background I am used to using structured formats like JSON or XML.

Am I just asking the wrong question here or am I yet to find the right tutorial to follow?

So far the guide that I found the easiest to understand was this one

Also searched through a community post on SO for resources but none I was most comfortable with the one mentioned above.

I am really really new to C so any sort of help will be very useful

3
  • 2
    Hi, I downvoted your question, I believe it does not belong here but on Stack Overflow.
    – f222
    Jan 22, 2021 at 13:38
  • 3
    The most important thing to understand right now is that C is extremely bare-bones compared to Python/JS. The standard library provides only rudimentary functionality and there is no culture of sharing packages/libraries through a common repository. That you can't find easy examples of how to write data in JSON or XML format is not surprising and you better get used to that. Jan 22, 2021 at 13:58
  • 2
    It's also too broad for Stack Overflow. Jan 22, 2021 at 18:21

1 Answer 1

6

One of the biggest strengths of C is also one of its biggest weaknesses: it has a very small runtime and standard library. This is a strength because it makes C very portable and highly reusable as a base for other things, even in compilers of other languages. It's a weakness because you have to look to third party libraries for things that feel like they're "included" in other languages.

So search the internet for "json C library" and see what you find. If you're using Linux, the better, more widely-used third party libraries will be in your package manager, so search that as well. I have a json-c package installed, and I don't do C development anymore. It's there as a dependency of other software. Some linux distros have a separate -devel package if you want to compile code against a library.

You can also look in GitHub for open source projects you know that use json. See gimp for example. Sadly, though, a lot of C programmers choose to reinvent the wheel for things like this.

1
  • You can also learn about the file I/O mechanisms that are available in C, and design a file format that you can implement using those mechanisms. Jan 22, 2021 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.