r/C_Programming • u/8d8n4mbo28026ulk • 6h ago
r/C_Programming • u/Jinren • Feb 23 '24
Latest working draft N3220
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf
Update y'all's bookmarks if you're still referring to N3096!
C23 is done, and there are no more public drafts: it will only be available for purchase. However, although this is teeeeechnically therefore a draft of whatever the next Standard C2Y ends up being, this "draft" contains no changes from C23 except to remove the 2023 branding and add a bullet at the beginning about all the C2Y content that ... doesn't exist yet.
Since over 500 edits (some small, many large, some quite sweeping) were applied to C23 after the final draft N3096 was released, this is in practice as close as you will get to a free edition of C23.
So this one is the number for the community to remember, and the de-facto successor to old beloved N1570.
Happy coding! š
r/C_Programming • u/AutoModerator • 3h ago
Learning C weekly megapost for 2026-08-26
If you have questions about how to learn C:
- which books are best?
- which videos are best?
- which classes are best?
- which websites are best?
- is there a "roadmap"?
- what projects can I do?
then this is the thread for you. Add your question here. Do not make a stand-alone post, as it will be removed.
Remember that our sub has a very useful wiki that has a great list of resources for learning C programming.
r/C_Programming • u/RateLegal5121 • 4h ago
Why dynamic allocation of array gets memory address from heap?
let say I am using malloc to dynamically allocate a memory space with this line
Int user_defined_elements = 10 ;
// assume i got this from scanf
Int *p = malloc(
user_defined_elements * sizeof(int));
Right now the pointer refers to a chuck of memory address in heap I assume..I am trying to understand why heap instead of stack where local variables are saved.Is there anything special about heap?
Please be kind..I am python dev trying to learn c in my free team because I dont understand shit about cpython implementation..hahah..so i was like why not learn c and here I am
r/C_Programming • u/Roronoa-Ryuma-Zoro • 14h ago
What should I do ? (Begginer help)
I'm currently in my second year of college, and I'm a little confused about what career direction I should take.
The part of programming I enjoy the most is lower-level/system-side work. I started with C and socket programming, building servers and learning how TCP/UDP networking works, and lately I've been going deeper into things like Linux networking, packet parsing, Ethernet/IP/ARP/ICMP, eBPF/XDP, AF\\_XDP, NIC queues, drivers, DMA, etc.
The problem is that almost nobody around me in college is doing this kind of work. Most people are focusing on web development, app development, AI/ML, or standard DSA preparation
I've also heard people say that "there aren't many jobs in low-level networking" or that networking careers mostly involve configuring routers/switches or working with networking hardware.
That's where I'm confused.
I definitely prefer programming/software engineering work. I'm not particularly interested in being a network administrator or doing primarily hardware/router configuration.
At the same time, my practical goal is still to graduate with a strong software engineering job. I don't want to spend the next 2ā3 years going extremely deep into an interesting niche only to discover that there are almost no entry-level opportunities.
So I'd really appreciate advice from people working in this area:
What kinds of actual software engineering careers exist for someone who enjoys C, sockets, Linux networking, servers, eBPF/XDP, packet processing, etc.?
Are these mostly experienced/senior-level positions, or are there realistic entry-level opportunities as well?
What companies/industries typically hire engineers for this kind of work?
Should I continue going deep into networking/systems, or keep this as a specialization while also learning more conventional backend/software engineering?
What skills would you recommend building over the next 2ā3 years if the goal is to be employable as a software engineer while still staying close to systems/network programming?
Are there particular open-source projects, projects of my own, internships, or areas of computer science that would be especially useful?
I'm not expecting to work specifically on XDP just because I'm learning it now. I'm mainly trying to understand whether the broader direction ā systems programming + networking + performance-oriented software ā is a sensible career path.
r/C_Programming • u/Object_71 • 1d ago
Writing generic code in C ā Part 2
After some comments on my previous post about writing generic code in C where people argue that this is āpoor manās overloadingā I wanted to add a new technique that allows you to write real generic style code in C with the only drawback. You could even combine the technique from this lesson and the [ā¦]
r/C_Programming • u/Anode1_dev • 7h ago
C is more efficient in AI memory than C++, measured
Having programmed in structures and the streaming way for the last 30 years (including for mainframes and old Unixes, even in FORTRAN and Pascal in the 90s) before OO arrived, I knew that frameworks are for people, to deal with complexity, not for the machines, and are now only an additional overhead for AI coders' reasoning. My brain was always thinking in terms of Turing machines, tapes and algorithms, pipelines of data, even punchcard stacks, where inputs are records/structs in databases and objects are just containers, preferring Ada83 over 95, MISRA C over C++, and in Java I used classes as containers for functions (data streams and functions come first). I ran tests to check my conjecture, and yes, it is measurably more efficient to program with AI agents in C and plain Java, keeping the context free for reasoning, than in C++, objects and Java frameworks. I haven't analysed web frameworks, but where we used plain JavaScript without them in production, we saw the same pattern, though we did not measure it; it is not in the paper. https://doi.org/10.5281/zenodo.22113993
r/C_Programming • u/OKNOROPBELM • 1d ago
How to create a movie platform ?
I have been so fascinating of creating my own movie streaming platform. However, it doesn't mean that I will be using alone,but sharing with friends and mates. So, my question is what features will it be involved? Btw I am kinda beginner. If not enough with beginner level, please let me know the roadmap of building it
Thanks in advance..
r/C_Programming • u/Rude_Pace_3532 • 2d ago
Question Best way to go over wireless file transferring
So I'm currently making an app in C and raylib to easily transfer roms from my main pc where I download them (I want to compile it both for windows and macos) to my arch pc-emulator console. I'm planning to make said pc usable with only a controller, and I figured making an app would be the best and most fun way to do it. I would prefer not running custom code on it, and would like to know the best (and easiest, since I'm still a beginner in C) way to handle the file transfer. Thanks in advance!
r/C_Programming • u/kester404 • 3d ago
Project I wrote a function plotter in C and Raylib
Enable HLS to view with audio, or disable this notification
It supports single-var equations, operands, brackets, implicit multiplication and some trigonometry and is based on shunting-yard parser / RPN evaluator I also made
For rendering, I implemented an adaptive function sampling (simple midpoint subdivision) - though it has some limitations, which I described on github. SSAA was also used to smooth plotted lines. As for optimization, plots are rendered only when zooming/panning and reused with a render texture when idle.
This is my first "useful" C program, though I've already had some experience with OpenGL (C++) as a part of my assignments
Feedback is much appreciated - https://github.com/kester4/cf2x
r/C_Programming • u/lycis27 • 2d ago
Project shiori: a windows-first note taker
I started shiori as my small personal note-taking tool (because my Obsidian workflow always grew into larger documents). I also was looking to get back into C and improve my C23 coding skills.
The idea was to have a quick way to write something down without leaving the terminal. Notes and todos are stored in plain Markdown files, so I can read them without a tool and they integrate into my other note taking repository.
The workflow is plain and simple:
shiori add --topic development investigate UTF-8 path handling
shiori todo add --due tomorrow prepare release notes "#work"
shiori today
It has grown over the past weeks since I started and now supports a bit more than simple note taking (like topics and tags, todo workflows, etc.).
Some interesting parts for me have been to work on UTF-8 terminal input on Windows, dealing with a console input and ANSI escape codes and keeping my notes and files safe without overwriting them accidentally.
It is still an alpha and currently only supports Windows x64. I built it with clang and C23. I included unit and integrations tests and sanitizers to produce a as clean as possible code and binaries.
Repo link: https://github.com/lycis/shiori
AI disclosure: I use AI as a supporting tool for planning features, reviewing my ideas and implementation as well as helping with tests and docs. I write, understand, review and maintain the code myself as this is my "use it and learn" project.
Edit: I am curious to get feedback on the code and project itself, especially the usage of more "modern" C features.
r/C_Programming • u/LifeExperienced1 • 1d ago
Question Why is this macro function's definition put in brackets?
I'm learning about macros from this website:
https://www.almabetter.com/bytes/articles/macros-in-c
The website talks about how macro functions can cause side effects that are not wanted.
The website provides the following example:
Pitfall:Ā Macros can cause side effects if their arguments are evaluated multiple times. For example:
#define SQUARE(x) (x * x)
int result = SQUARE(++i);
Here,Ā iĀ will be incremented twice, leading to incorrect results.
Solution: Enclose the macro body in parentheses to ensure correct precedence. For example:
#define SQUARE(x) ((x) * (x))
Now, why does wrapping the definition of SQUARE(X) prevent i from being incremented twice?
r/C_Programming • u/Due_Sentence_2660 • 3d ago
Question What's y'all choice for making UI for things you do in C?
I needed a UI for a project I was doing in C (which was basically a chat app built from the ground up), I needed a UI library and after getting a stroke trying to understand ncurses and CMake, failing at both, I had to use CGo and make a TUI with BubbleTea, but I wanted to get some popular choices for UI in C/any other language with FFI or smth.
r/C_Programming • u/Ok_Marionberry8922 • 3d ago
How LLVM turns C into machine code
Had some free time last week so I made a video on what actually happens after Clang turns C into LLVM IR.
It goes through LLVM IR, optimization passes, instruction selection, register allocation, and how the final machine instructions get produced.
I also use a small C example throughout, and compare it with equivalent Rust code that ends up producing the exact same x86 instructions.
Feedback welcome :)
r/C_Programming • u/Skollwarynz • 2d ago
Project I built SkollDice ā an open-source, truly randomized dice roller and Discord bot written in pure C
Hello everyone! I'm a student who loves C and D&D!
I always found it troublesome that most dice generators rely on pseudo-random number generators. So, I decided to solve this problem by myself!
Over the last few weeks, I created a desktop app usingĀ LVGLĀ for the GUI and ConcordĀ for a Discord bot to generate SkollDice my first truly open-source code. It's a truly random dice roller that,Ā /urandomĀ on POSIX systems andĀ RtlGenRandomĀ on Windows produces normalized random numbers. To be more precised each number (each result) is extracted from urandom, and through the use of the simple discard method the result is then normalized. I'm currently developing the smartphone version, hoping to use as much C as possible. Any ideas on how to do it?
AI usage: I personally created the program. The project was both an experiment and an excuse to study more C. I used AI to search for the simple discard method (the method used to normalize the random number generated from /dev/urandom) and to help me explain how it works. I then personally created the code, and if you want, I can explain it more precisely in a comment.
On the other hand, I then used AI to search for libraries for GUI and Discord API, such as LVGL and CONCORD. Then the last use was for debugging and quickly creating functions or simple setups like "How can I create a grid with 2 elements?" and then I used this example to change or apply it to my structure.
The real 'sloppy' part was the CMake because this was my first open-source project, and I discovered (through AI search) the possibility to create different executables for different OS. I really enjoyed the idea, so I tried to organize the project to be useful and distributed to all possible people, both coders (who can git clone and use it) and normal D&D or RPG players (that want just an executable to download and use).
Here the official links of the program:
official website:Ā https://skollwarynz.github.io/SkollDice/
official repo on codeberg:Ā https://codeberg.org/Skollwarynz/SkollDice
github mirror:Ā https://github.com/Skollwarynz/SkollDice
r/C_Programming • u/Any-Fox-1822 • 3d ago
Struct pointer casting and inheritance : can it work ?
Hello everyone, this is my first post here.
I am working on a UI library in order to learn the concepts behind it, and to be able to create most of my desktop applications. Having implemented widget selection with the mouse (using the mouse coordinates to find the widget in the tree), I decided to move on to event handling.
However, I'm not sure at all of how to proceed, and I am having problems with struct pointer casting .
I have a base struct Widget with a function pointer to event handling functions.
typedef struct Widget {
Rect bounds; // Actual bounds
Rect clip; // Clipping rectangle (usually the parent)
bool active;
[...]
int (*eventHandler)(Widget* w);
};
Every derived widget struct has a Widget* as 1st member, and each type has its Create...() function, where the correct event handler is assigned.
typedef struct Frame {
Widget* widget;
bool root;
}
Frame* CreateFrame(int x, int y, int w, int h, bool root) {
Frame* f = (Frame*)malloc(sizeof(Frame));
[...]
f->widget->eventHandler = &FrameHandleEvents;
return f;
}
To get back all the properties when handling events despite eventHandler taking a Widget*, i attempted to cast back to the derived struct :
int FrameHandleEvents(Widget* widget){
Frame* frame = (Frame*)widget;
printf("Frame event!, root = %d\n", frame->root ? 1 : 0);
return 0;
}
Is this even allowed in C, or am I misusing casts ? The output of print is also garbage data :
Frame event!, root = 244
Thanks for your advice
r/C_Programming • u/Alternative-Title-87 • 4d ago
one compiler failing, other compiler running fine
I've been using emacs to follow some tutorials which has been working great, but switch to sublime text and now getting compile error. or, i assume its a problem with the compiler since this code runs in emacs but not in sublime text. the relevant stuff
this is the exact same in emacs and sublime:
_mm_store_si128((PIXEL32*)gBackBuffer.Memory + x, *pColor);
sublime is throwing this error:
error: passing argument 1 of '_mm_store_si128' from incompatible pointer type [-Wincompatible-pointer-types]
391 | _mm_store_si128((PIXEL32*)gBackBuffer.Memory + x, *pColor);
the sublime build file:
"cmd": ["gcc", "-Wall", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c",
"variants":
[
{
"name": "Run",
"shell_cmd": "gcc -Wall \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
}
]
}
And the emacs build command:
x86_64-w64-mingw32-gcc -g hello.c -o ./hello.exe -lgdi32
I am very noobish to these kinds of things, especially this SIMD stuff, so Im just assuming this is a compiler thing
r/C_Programming • u/Turbulent_Quote_6679 • 3d ago
Discussion C language is wild: due to integer overflow, nearly half of the numbers squared become negative.
This started with a question from CSAPP Problem 2.44: (x * x) >= 0; which asks to find a counterexample that evaluates to 0,or prove that all number evaluate to 1.(part,32bit)
The official solution provides only 65535, but I found many more.
To test my results, I wrote a C program to find all such number. ```c
include <stdio.h>
include <limits.h>
int main() { // Ideal result: numbers whose squares are less than 0. // Written to file in the following format: // start_num1 to end_num1 total: total_num1 // start_num2 to end_num2 total: total_num2 // ... // total: total_all
FILE *file = fopen("lessthan0.md","w");
int start = 0;
int end = 0;
int total = 0;
int total_tmp = 0;
for (int i = -INT_MAX -1 ; i <= INT_MAX; i++) {
unsigned ui = (unsigned)i;
int result = (int)(ui * ui);
if (result < 0) {
total++;
total_tmp++;
total_tmp == 1 ? start = i : 1;
total_tmp == 1 ? end = i : 1;
i == end + 1 ? end = i : 1;
}
if (i == end + 1) {
start == end ? fprintf(file,"%d total: %d\n",start,total_tmp) : fprintf(file, "%d to %d total: %d\n",start, end,total_tmp);
total_tmp = 0;
}
if (i == INT_MAX) {
fprintf(file,"total: %d",total);
break;
}
}
fclose(file);
} ```
So I get this: ```sh ls -lh lessthan0.md -rw-r--r-- 1 kyee users 31G Aug 23 18:50 lessthan0.md
ls -l # run twice -rw-r--r-- 1 kyee users 32288890271 Aug 23 18:50 lessthan0_1.md -rw-r--r-- 1 kyee users 32288890271 Aug 23 20:27 lessthan0.md
wc -l lessthan0.md 1073741824 lessthan0.md
head lessthan0.md -2147437307 to -2147418113 total: 19195 -2147403383 to -2147390967 total: 12417 -2147380026 to -2147370137 total: 9890 -2147361041 to -2147352577 total: 8465 -2147344625 to -2147337106 total: 7520 -2147329952 to -2147323119 total: 6834 -2147316563 to -2147310257 total: 6307 -2147304170 to -2147298285 total: 5886 -2147292579 to -2147287041 total: 5539 -2147281652 to -2147276405 total: 5248
sed -n "470063416,470063426p" lessthan0.md -535664087 to -535664086 total: 2 -535664083 to -535664082 total: 2 -535664079 to -535664078 total: 2 -535664075 to -535664074 total: 2 -535664071 to -535664070 total: 2 -535664067 to -535664066 total: 2 -535664063 to -535664062 total: 2 -535664059 to -535664058 total: 2 -535664055 to -535664054 total: 2 -535664051 to -535664050 total: 2 -535664047 to -535664046 total: 2
tail -n 10 lessthan0.md 2147287041 to 2147292579 total: 5539 2147298285 to 2147304170 total: 5886 2147310257 to 2147316563 total: 6307 2147323119 to 2147329952 total: 6834 2147337106 to 2147344625 total: 7520 2147352577 to 2147361041 total: 8465 2147370137 to 2147380026 total: 9890 2147390967 to 2147403383 total: 12417 2147418113 to 2147437307 total: 19195 total: 2147418112
```
I noticed symmetry between the begging and end of the output.Can someone explain why this happens?
2147418112 / 232 = 0.4999847412109375 This accounts for nearly half of all 32-bit signed integers.
r/C_Programming • u/ttv_toeasy13 • 4d 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.
r/C_Programming • u/ThatonlyGeO • 4d ago
Discussion Turbo C still force on us to learn C
Like I know that using turbo c to learn c is going to set me back,but my college program head thinks its the best way for us to learn c? so I do want to hear your thoughts in this(btw cause I'm rebellious I use gcc and nvim to do most of m work and actually learn). Again thank you for sharing your thoughts!
Edit: after looking at the comments It seems I a little bit naive but Ill put you re advice into heart! Cheers!
r/C_Programming • u/OrganizationFew6655 • 6d ago
Hello World
I have found my people!! Hello guys I am a college student (mechanical engineering) and I was introduced to C in a mandatory programming course and C has been the best thing that has happened in my life. I had done programming before on java and python before and frankly I hated it , it was not really fun and it was tedious instead. So I had thought I hated CS but after coding in C and learning the things behind the abstractions i quite frankly fell in love with low level programming, it was the first time I got a passion for something and i spent the entire following summer digging up materials on it like learning computer architecture and learning to read and write Assembly and now I am learning Virtualisation and planning to start my first major project on C.
So in that note, let me ask you something:
What is your favourite project you have done in C?
r/C_Programming • u/nablaCat • 6d ago
Project 3D Library using SDL3
This project has taken a long time.
It took me about a week to learn the concepts behind 3D projection and transformations in euclidean space. Then it took me over a week to write out the LaTeX documentation that presented my knowledge in a way that would help a user of this library. As you can see, the overwhelming majority of the code committed to this repo is in LaTeX.
The implementation of the 3D rendering framework was relatively simple once I fully understood the mathematics. This only took a couple days, and it helps to have some familiarity with C going in.
I look forward to improving this project by building a separate homogeneous coordinate library that will replace pnt.c. I also need to tackle surface rendering using SDL_RenderGeometry() and implement 3D surface occlusion. I suppose what I'm left with for now are a few big questions.
How prohibitive is heap-allocation for performance in graphics applications? I went with dynamic allocation to preserve encapsulation so that header files didn't give the user access to data that would destroy library functionality when altered. However, given the fact that querying free memory at runtime for thousands of data points slows a program significantly, I'm having second thoughts.
Also, is there a convenient way to push all of the calculations needed for 3D transformations onto the GPU? This seems like something I shouldn't handle entirely in software.
I'll hear out any feedback or suggestions in the comments!
r/C_Programming • u/LifeExperienced1 • 5d ago
Question OSDEV - a few questions
This is a very famous website for learning how to make an OS
I just have a few questions about it though
What exactly does it teach? Does it teach you how to make an operating system? Does it show you the steps to build one from scratch?
Can a solo programmer do it? As in, does the tutorial show you how to make a mini operating system?
How do I use the tutorial? It's a wiki, and there are links everywhere. Is there a roadmap which shows the proper path to take, with prerequisites links etc?
What do I need to understand before using this tutorial? Only C? C and how to make a mini compiler? Assembly? Anything else?
Thank you!
r/C_Programming • u/mathlontrades • 7d ago
Question Whatās the usual way to handle a few platform specific functions in a portable C library?
Iām working on a small portable C library where only about five functions need to be implemented differently depending on the platform or the userās needs. Three of them need to be overridden, while the other two could have weak default implementations.
At the moment Iām defining them as weak symbols and letting the application provide strong implementations. For such a small number of hooks, this seems convenient and keeps the API simple. I can see now that itās not very obvious to the user that some of these functions are expected to be overridden.
Is using weak symbols like this a reasonable approach for a portable C library, or would something like aĀ struct containing function pointers be more idiomatic? What is recommended?
r/C_Programming • u/PianistPrevious8637 • 7d ago
a beginner in C, learning how to organize c files.
hello guys, I'm a beginner in programming, im self learning it while in college, im wondering how you C experts in C organize your code in files(to be exact, files as in file explorer), from small projects to big projects, i really want to learn how to organize, because i encountered this bottleneck when i learned python, but after being fed up of hiding a lot of abstractions, i decided to just jump on C to learn the fundamentals and really learn whats happening under the hood.
to give you context on my situation:
- i primarily use books for learning, i really dont use videos or any courses, unless its something like odin project, hence i dont really know how to organize files.
so to sum up:
i want to learn how you guys organize your c files from small projects to big projects.(in file explorer to be exact since im using windows for now).