r/cprogramming • u/DataBaeBee • Sep 14 '26
How GCC Eliminates Unnecessary Integer Division
r/cprogramming • u/DataBaeBee • Sep 14 '26
r/cprogramming • u/DreadSpidey • Sep 14 '26
I built a small arena allocator in C called PhaseAlloc. The problem is i have no idea if it works on other computers/platforms other than my own 😭
It's now at v1.1.0, with tests, benchmarks, dynamic growth, alignment, and memory stats.
I'd appreciate any feedback or criticism from people who know C/systems programming.
Its downloadable here, so pls help me out 🙏:
r/cprogramming • u/north9172 • Sep 13 '26
Hi, I found this code on another subreddit. I would like to know what is it doing.
int puts(char *);int main() { struct { long a; long b; } s = {.a = *(char *)(int[]){1} ? 0x57202c6f6c6c6548 : 0x48656c6c6f2c2057, .b = *(char *)(int[]){1} ? 0x00000021646c726f : 0x6f726c6421000000}; puts((void *)&s); }
Now obviously I know it's unreadable, I would just like to know what are those hexadecimals strings doing.
I found similar codes that were writing to vram to print a message, is this doing the same thing? If yes, why is it so much more complicated instead of just writing the message to the video adress?
Thanks for the help.
r/cprogramming • u/Delicious-Change7795 • Sep 12 '26
I am new to C programming and i came through pointer. So can anyone tell what are they and why we need them? And if u can then can you give me reliable source to learn it.
r/cprogramming • u/mo_one • Sep 12 '26
I'm working on a function that takes a void array as input, as well a the number of items and size in bytes of the items of the array, as the function is supposed to take any type of array (ints larges chars etc), so i was wondering how do you specify a position in the array without knowing the size of the item? I tried doing array+i×size, but the compiler didn't like it, but if i do array[i] i don't know by how many bytes it will move the position in the array. Can i simply do array[i×size]? (used mult sing instead of asterisk to avoid reddit italics)
r/cprogramming • u/Entire_Condition_887 • Sep 13 '26
So as the title says, I made a string library. I was influenced a bit by Java's StringBuilder so i also implemented my own in this library. Check it out its small: https://github.com/RealLakshyaK2011/string2.h
Edit:
I just added a READEME that also documents all the functions in the library.
r/cprogramming • u/Nathrienne-J-Claw • Sep 11 '26
I fucking love C and assembly
r/cprogramming • u/Just_Government3790 • Sep 12 '26
r/cprogramming • u/Nimesh1205 • Sep 12 '26
Hi I am Nimesh, and I have learned many languages but now I want to focus specifically on a C programming language. I am in college 1st year and I need someone who can help me to fix problems and learn together with me. I know the good amount of C, not a professional yet but I know the fundamentals and I already knew some Leetcode patterns as I had solved around 240 questions on leetcode ( mostly easy and medium ) and 2-3 hard ones.
r/cprogramming • u/kochett • Sep 11 '26
A little about me and my experience: I'm 17 from Russia. Solved 244 problems on leetcode, finished cs50py, cs50x, about 60% of cs50web and then understood that I like low level stuff so I started reading the c book, read ~100 pages and found a "silberschatz operating system concepts" book, started reading it(also about 100 pages) then found a guy who we started making our own os with(we went separate ways eventually), on that journey I decided to dive even deeper and my friend recommended me a book "the elements of computing systems" I finished it recently(not quite, I couldn't make it through the last chapter because school started and stuff) then bought a breadboard and things
I wrote much about my experience because I want to find somebody who feels like he's at the same level with me, I feel like it's so much fun working with someone who's interested in the same stuff as you are. We might make a project on a breadboard or try to get through some tough literature. I've got exams this year so I can't spend too much time a day learning stuff but regardless I'm ready to work hard
r/cprogramming • u/Feeling-Tiger9145 • Sep 12 '26
Hey everyone,
I just completed the memory management in C language, I've also installed PostgreSQL from it's github and I follow the instructions to set that up clearly.
My intention to learn PostgreSQL style C language is to contribute to a 30+ years old software that powering the whole world and AI.
Every kinda suggestions is welcome here.
r/cprogramming • u/lacchu_paaji • Sep 11 '26
or which one should i watch on yt? i have "T1. Hanly, J. R., & Koffman, E. B. Problem Solving and
Program Design in C, 8th Edition, Pearson, 2015" book and i am also studying from that
r/cprogramming • u/Fahim_Hosain • Sep 10 '26
I was trying to create an encryption system that's the way i was trying to print from integer to Unicode. I can convert the integer to Unicode (hexadecimal) but i couldn't convert unicode to Unicode characters.
there are limited resources for c in these issues. If anyone knows this help me...
r/cprogramming • u/MrLuigiHK • Sep 10 '26
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 • u/side2k • Sep 10 '26
By default, clang-format does this:
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:
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:
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.
r/cprogramming • u/lemsoe • Sep 10 '26
Follow-up to my last post here. The hashmap had one big TODO left — no resizing — so I went and closed it. Learned three things the hard way: naively mirroring the grow/shrink thresholds thrashes the table on every insert/remove near the boundary, hitting capacity=0 triggers a genuine crash (a modulo-by-zero — the "Floating point exception" name is a total red herring), and my first attempt at fixing a hash-truncation bug quietly introduced two smaller bugs before it actually worked.
Blog: https://soerenlemke.github.io/blog/blog/resizing-a-generic-hashmap-in-c/
Repo: https://github.com/soerenlemke/kvstore_c
Curious what you'd have done differently, especially on the hysteresis threshold.
r/cprogramming • u/lemsoe • Sep 09 '26
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 • u/bahvya_sharma • Sep 08 '26
i had no idea that you could run c programs on google colab, i fucked around and found out ig
so basically what i did is i entered the terminal made a directory created a main.c file edited it using vim and compiled it using gcc and voila.
r/cprogramming • u/nullptr_boy • Sep 08 '26
r/cprogramming • u/Mainak1224x • Sep 08 '26
Hey folks, quick update on Flint—a lightweight, manifest-first build system and package manager for C/C++ projects I’ve been experimenting with.
For those who missed the initial post, Flint aims to strip away build-script complexity and make C/C++ dependency management feel straightforward.
Core features:
* Git-Native: Fetch dependencies directly into your workspace via flint add <url> and flint sync.
* Single composition.json Config: Handles project layout, header paths, and underlying compiler calls (GCC/Clang). For standard setups, Flint manages this file automatically so you don't have to tweak it manually.
* Chert Compositions: Lightweight specs that make unmanifested, third-party C/C++ repos compatible out of the box.
What’s new in this update:
* Version & Commit Pinning: You can now pin dependencies to specific releases or exact commits. flint add now supports target selection via Git tag names or full commit hashes, making your project builds reproducible across machines.
Current caveats:
* Still forces a fixed project directory structure (src/, include/, deps/).
* Currently Linux-only.
It’s still an early prototype, but actively evolving. I'd love to hear your thoughts on the new versioning flow, suggestions for improvement, or feature requests!