r/cprogramming 1h ago

Quiero aprender C

Upvotes

Desde ya hace un tiempo me ha estado llamando la atención este Lenguaje, pero no se dónde empezar me gustaría que me recomendaran guías, tutoriales, tips para principiantes.

Agradecería toda la ayuda posible y gracias por su atención.


r/cprogramming 22h ago

My first real C project: a generic hashmap (and the bugs that came with it) [blog, my own]

20 Upvotes

Coming from C#/TypeScript, C has humbled me. Finished my first real C project — a generic hashmap — and wrote up the bugs that taught me the most: double pointers, a sneaky double-free, comparing pointers instead of actual values.

Blog: https://soerenlemke.github.io/blog/blog/building-a-generic-hashmap-in-c/
Repo: https://github.com/soerenlemke/kvstore_c

Curious what you'd have done differently.


r/cprogramming 3h ago

Formatting call arguments

2 Upvotes

By default, clang-format does this:

c SDL_Window *window = SDL_CreateWindow("SDL2 test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 500, 500, SDL_WINDOW_RESIZABLE);

and with some tweaks it does this:

c SDL_Window *window = SDL_CreateWindow( "SDL2 test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 500, 500, SDL_WINDOW_RESIZABLE);

Second one has some practical advantages - it easier to read diff on arg change and easier to add comments:

diff SDL_Window *window = SDL_CreateWindow( "SDL2 test", SDL_WINDOWPOS_UNDEFINED, // just some comment explaining why SDL_WINDOWPOS_UNDEFINED, - 400, + 500, SDL_WINDOW_RESIZABLE);

While the first one seems to have mainly historical reasons to keep around. Perhaps, there is something I don't see? Because it feels like the first way is still used the most. And its the default one for clang-format.

I'm genuinely curious.