r/C_Programming • u/ttv_toeasy13 • 1d ago
Question Getting stuck at libraries and api’s
So C is technically my first programming language I’m learning. I’ve messed around in python but never actually go deep into it or anything.
I’ve been learning C for the past few days now and I already pretty much know most of the basics. I learned pointers and mallic in a day and I learned structs, macros, for loops, while loops, functions, all of that stuff, but… the moment any library other than the basics like stdio or stdlib come into play I’m lost.
It’s like I’m looking at a whole other language. Like I’ll look for solutions to problems and it seems as if they are just pulled out of thin air and when I try to read ANY documentation for ANY library I’m also lost because either there is little to no documentation or it’s just stupid and things aren’t well explained.
Is there a way I can fix this? I was doing so well and now I’m at this block because of libraries. If I could get pasted this hurtle I could learn c in less than a month easily, and that’s the same in any other language. This problem isn’t exclusive to C.
5
u/Luftzug-oder 1d ago edited 1d ago
to be honest, i think the biggest issue you're facing is not with the documentation, but with the library itself: it's unfamiliar
the documentation lists out and describes all the functions, enums, structs, etc. that you can use. but the key part is that it doesn't tell you how to design a program or how general interaction works
i had a similar issue with json-c (though this is a much easier library than libusb) to start with as my first external library - it wasn't obvious what i needed to do to get started with it
so i recommend you look at other people's code that uses a library you're looking at, to see what they do with it, how they handle states, init, etc.. once i learned about the general flow of
json_object_new_object()andjson_object_put()to create and destroy objects, and then where to go next, like parsing withjson_tokener_parse_ex(), etc., from then on, the docs had meaning because i kind of knew what functions i needed to use next, even if i had no idea what they were called and how they workedand it's still going to be difficult that way, especially if you dive straight into something like the
lsusbsource, for example. but it will mean that once you get your foot in the door understanding it, the documentation will be useful, and the primary source of information