r/C_Programming • • Feb 23 '24

Latest working draft N3220

134 Upvotes

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 • • 2d ago

Learning C weekly megapost for 2026-09-30

2 Upvotes

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 • • 20h ago

I want a career in C/low-level programming, but the path feels invisible compared to web dev. What do I build?

53 Upvotes

TL;DR: I’m learning full-stack (Vue/Go) because the job path is obvious, but my true passion is C, C++, and low-level systems. I want a career in low-level programming, but I have no idea what projects to build or what jobs to aim for to actually get hired.

Disclaimer

I'm not really good at structuring my thoughts to words & English is my 2nd language. I'm sorry if there are weird sentences that are present in this post.

Background

I'm a 3rd semester CompSci major student in Indonesia. My campus isn't really know for teaching low level programming rather it's known for their competitive programming & CTF team (Jollybee & PETIR).

My first language was C++ & Pascal, I learned C++ because of a course in my middle school requires me to learn how to use Arduino. That was the first time i got introduced to programming & i got hooked.
At high school, i was trying to participate in the OSK CompSci subject. Though i failed miserably, i got even more hooked with learning C++. After i tried learning C++, i found out that C++ is actually an extension of C & learning this makes me want to learn more about low level programming.

At uni, there are courses that focuses on using C & C++ though they are strictly for competitive programming. The courses are Algorithms and Programming (C), Data Structures (C), and Algorithm Design Analysis (C / C++). I've already completed the first 2 course that I mentioned & I'm on my way to do the 3rd course.

Because of those courses, i've been trying out more competitive programming even though i still suck (Codeforces Rating: 858, Leetcode: 89 solves; 66 easy, 23 medium). but in the span of those years, i've only been taught on how to do competitive programming & not actually building apps.

I got some exposure on how to make apps & participated in hackathons (even though i don't even have any knowledge on how to make apps). Because i don't even know how to make apps, i vibecoded. Everytime I vibecode I would feel nausea and just feel guilty because i don't even understand what am I doing, i felt the whole app is just a blackbox. I am also tired of "AI slop" that is present in this current era, i see every hackathons are just Business Case Competition but with a webapp MVP. I've never seen any new inventions or something that came out from hackathons that i participate in, all of them are just purely B2B or B2C SaaS.

After that 1 whole year, in this 3d semester i decided to stop & i wanted to dedicate myself to go back to my roots to learn C & low level programming. One of my friend recommended me to try CTF with Reverse Engineering & Binary Exploitation topic because it covers low level. I've also tried finding resources on my own (OSTEP, Beej's Guide, CSAPP). And I already took a step to learn How to make a 4-bit Adder in Minecraft.

Dilemma

But i'm still confussed. What am I learning C for? Rn I'm also learning Fullstack using Vue + TS & Go + Gin, with these 2 I understand the direction: making web apps. but with C / C++, there isn't any problem that I can solve yet using C / C++. Most projects that I've seen are making a "web server from C", "making a database engine using C", "making a redis clone". My last attempt at using C / C++ to solve my problem is by making an ESP32 send a WoL Packet to wake my PC for RDP.

The reason that I'm stuck is because I need to find a job & in the future I want to use low level for my main job. My knowledge right now by learning low level & C gives path to making tools, CTFs, and competitive programming.

What i wanted to know from this community is:

  • What does a junior portfolio for a low-level/systems developer actually look like?
  • Aside from writing database clones or making web servers or doing CTFs, what practical C/C++ projects actually get you hired?
  • What specific job titles should I even be looking for if I want to work close to the metal?

Thank you for your time


r/C_Programming • • 3h ago

Question Why i'm not getting the correct output for Tower of hanoi program?

0 Upvotes
//Tower Of Hanoi


#include <stdio.h>


void TOH(int n, int A, int B, int C){
    if(n > 0){
        TOH(n-1, A,C,B);
        printf("(%d, %d)\n",A,C);
        TOH(n-1, B,A,C);
    }
}


int main(){
    TOH(3,1,2,3);
    return 0;
}
----------------------------------------
//Output in terminal

$ gcc toh.c
$ ./a.exe

(1, 3)
(1, 2)
(3, 2)
(1, 3)
(2, 1)

Expected output is
(1, 3)

(1, 2)

(3, 2)

(1, 3)

(2, 1)

(2, 3)

(1, 3)

Why is this happening? Any explanation or reason for it?


r/C_Programming • • 23h ago

The first time I realized that understanding code is more important than memorizing syntax

14 Upvotes

When I started learning programming, I spent a lot of time trying to remember syntax.

I thought being good at coding meant remembering how to write loops, functions, conditions, and other things without looking them up.

But after solving more problems, I realized that I can always look up syntax. The harder part is actually breaking a problem into smaller steps and figuring out what the program needs to do.

Now I'm trying to focus more on problem-solving and understanding concepts instead of trying to memorize everything.


r/C_Programming • • 1d ago

Question I can think clearly with type* foo and not with type *foo, help me understand?

77 Upvotes

I'm relatively new to this, but it seems there aren't many who prefer this notation. And while I'm not really feeling pressured to change what I'm doing, I wanna make sure I'm not missing anything too obvious or important. The '*' just feels like it is a part of the type specifier. And I'm pretty blind to any reason to do type *foo.

Hope I'm not beating a dead horse with this one. Just wanna understand a little better.

edit: I am not one to ever declare multiple variables on the same line. Maybe if it happens to be easier on the eyes. Otherwise, not worried about that part.
thanks for the responses!


r/C_Programming • • 1d ago

Question Why unrolled has more stable execution time than not unrolled loop?

6 Upvotes

I was playing around and testing performance of writing to array in a loop. Of course unrolling loop and writing to is faster but why execution time is more consistent? In one case I was writing to 16 consecutive addresses with average execution time of around 290 ticks, in second case I was writing only to 2 consecutive addresses and most often execution time was around 420 ticks but sometimes it was above 1000.

Why this happens? Why only sometimes? Why there is such big change in time in second example but not in the first one? I used gcc to compile code

#include <time.h>
#include <stdio.h>
#include <stdint.h>

#define len 4096

int main()
{
uint16_t a[len] ;
int d = 100, num = 0 ;
uint64_t b ;
clock_t t, no, jo ;

no = 0 ;
jo = 0 ;

while (num < 1000)
{
t = clock() ;

for (int j = 0; j < d; j++)
    {
    for (uint16_t i = 0; i < len; i += 16)
        {
        a[i] = i ;
        a[i+1] = i+1 ;
        a[i+2] = i+2 ;
        a[i+3] = i+3 ;
        a[i+4] = i+4 ;
        a[i+5] = i+5 ;
        a[i+6] = i+6 ;
        a[i+7] = i+7 ;
        a[i+8] = i+8 ;
        a[i+9] = i+9 ;
        a[i+10] = i+10 ;
        a[i+11] = i+11 ;
        a[i+12] = i+12 ;
        a[i+13] = i+13 ;
        a[i+14] = i+14 ;
        a[i+15] = i+15 ;
        }
    }

t = clock() - t ;
no += t ;

t = clock() ;

for (int j = 0; j < d; j++)
    {
    for (uint16_t i = 0; i < len; i += 2)
        {
        a[i] = i ;
        a[i+1] = i+1 ;
        }
    }

t = clock() - t ;
jo += t ;

num ++ ;
}

printf("Arr 1: %ld\nArr 2: %ld\n\n", no/1000, jo/1000) ;

return 0 ;
}

r/C_Programming • • 3d ago

Any Good Books on Graphics?

15 Upvotes

Hi,

I'm looking for any textbooks on Graphics in C. Does anyone have any recommendations?


r/C_Programming • • 3d ago

Finished Chapter 17 of C Programming: A Modern Approach — Starting Data Structures Next!

77 Upvotes

Finally finished Chapter 17, “Advanced Uses of Pointers,” in *C Programming: A Modern Approach (2nd Edition)* by K. N. King!
I started learning C about three months ago, so getting this far feels like a pretty big milestone for me.
Next, I’m starting *Data Structures and Algorithm Analysis in C (2nd Edition)* by Mark Allen Weiss.
I’m really looking forward to diving deeper into data structures and algorithms in C!


r/C_Programming • • 3d ago

How to learn to actually make programs that can work with a gui?

19 Upvotes

So i've got a small familiarity with the standard c library , I can make a calculator a caesar cipher , a image copying tool , but it all runs in the command line.

No one in the general public will ever use the command line.

Now , my question becomes , how does one actually begin the path of making a proper general user interface for their program in a way that approximates the way the pros do it.

I assume that a custom Gui starts with, like some kind of window system. Call giving you a rectangle to work with. And then you stretch out all your materials on the rectangle.\n But I'm not sure how one would say Develop a calculator that visually looks like a calculator and can detect your mouse inputs and send a signal to your actual c program.

Ai keeps trying to get me to use the windows message box and I know d*** well.That the pros at their core aren't using message box.


r/C_Programming • • 3d ago

The first time I actually understood what happens when a C program runs

30 Upvotes

When I started learning C, I mostly thought about code in terms of lines and syntax.

Recently I started paying more attention to what actually happens when the program runs — compilation, memory, variables, stack, etc.

It made me realize that understanding what happens “behind the code” makes programming concepts much easier to connect.

What programming concept made you stop thinking only about syntax and start understanding what was actually happening underneath?


r/C_Programming • • 2d ago

Discussion Employment opportunities for C developers?

0 Upvotes

What would be some good projects so that I could display my understanding of C for employment?

I have a decent handle on pointers and Memory Management, and I am somewhat of a Picasso with writing Algorithms in C also. All of my experience has been on x86 arch and I'm afraid I'll have to learn ARM variants of C, or pick up C++, for employment opportunities!

  1. What are my employment options with pure C?

  2. Is C still employable today, with languages such as Rust/Go offering more safety mechanisms for Memory handling and AI being able to handle low-level systems tasks?


r/C_Programming • • 3d ago

Types with range checks

5 Upvotes

I've been pondering about a different way of dealing with overflows.

C compilers have type checks that ensure you don't assign a value to a variable of the wrong type.

Imagine I had a different way of declaring bounded types, something along these lines:

const int strlen=100;
char string[strlen];
int[0..strlen-1] strindex;

I can cast strindex into an unbounded int, but I can't automatically cast an unbounded int into a bounded int:

int index = strindex; // allowed, can assign bounded int to int
strindex = index; // not allowed without cast/check
strindex = (int[0..strlen-1]) 0; // trust me bro

Since you have ranges you could now also do things like:

forall (int[0..strlen-1] strindex)
string[strindex] = 0;

The thought is somewhat halfbaked, but although annoying, this would flag up _every_ assignment at compile time that could potentially have caused a value to get out of bounds.

A similar bounded type could be set for pointers.

Thoughts?


r/C_Programming • • 3d ago

Project WSERVE: Static Web Server in Pure C

17 Upvotes

Hi,

To gain more experience in low-level programming, TCP/IP networking, and HTTP, I built wserve, a static IPv4 Linux web server written in pure C. No external libraries used. Even the parser is written in pure C. It supports a subset of HTTP/1.1. It supports GET and HEAD methods.

I am open to constructive criticism. The project is open for contributions.


r/C_Programming • • 4d ago

Project I built a modern formatting library

Thumbnail
github.com
26 Upvotes

Hey, a while ago I wanted a nicer alternative to printf. I always enjoyed using the modern python-like formatting libraries: fmt for C++, and rust's format!/pritnln! macros.

So I attempted to port them to C! And I must say, it was quite the challenge. C doesn't have the nicer features that are required to make this work: generics, compile time code generation, better type safety, etc.

But C has macros! Macros let you do all kind of crazy stuff, but most of all, did you know that C macros are Turing-complete? Well they aren't strictly-speaking, but they can be used to create an (almost) infinite loop thanks to recursive evaluation.

Anyway, I'm sharing this project hoping you'll enjoy it and it will inspire you in your usage of macros.

This project is still a work in progress, the main missing feature is float formatting, but so far there is: * Integers/Strings/Char/Array formatting * Style and color support for most terminals * Output to FILE*, fd, and memory buffer * Flushing & Buffering * User defined formatter/formatting for custom types

Check it out: https://github.com/ef3d0c3e/format


r/C_Programming • • 3d ago

Question Best GUI C profiler on Linux

8 Upvotes

Basically the title. I really want something graphical, i hate reading command line output. I know there is perf on linux but it has command line output. Also, are there specific profilers for specific types of application? Thanks for reading.


r/C_Programming • • 4d ago

My teacher says I’m using GCC incorrectly is gcc main.c -o main actually different from gcc -o main main.c?

207 Upvotes

He told me that using gcc main.c -o main is incorrect because the source file and executable are supposedly placed incorrectly. He suggested that I use gcc -o main main.c instead. Unfortunately, I should’ve asked him about it in class, but when I got home to study, it popped into my head.

I've done some research, and I commonly see programmers using gcc main.c -o main but I can't find the answer that I'm looking for unless someone has a link to share. I don't know if my teacher is correct, so I'm wondering... does this just come down to personal preference, or is there actually a difference between the two commands here?


r/C_Programming • • 3d ago

Need Help With Project

2 Upvotes

I'm building a program that takes a decimal number and outputs the binary equivalent. Its almost finished, except that with certain numbers it doesn't output the full value. For example, inputting 3 does output 111 ,but inputting 2 outputs 1 instead of 10. I noticed that it only doesn't work for numbers whose binary equivalents end in 0 (2 = 10, 4 = 100 etc.), but I don't know how to fix it. Please help.

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>


void intToStr(int number, char *str)
{
    int i = 0;


    while(number > 0)
    {
        str[i++] = number % 10 + '0';
        number /= 10;
    }


    str[i] = '\0';


    for(int j = 0, k = i - 1; j < k; j++, k--) 
    {
        char temp = str[j];
        str[j] = str[k];
        str[k] = temp;
    }
}


void binaryConvert(int regNumber)
{
    int binaryDigit[8];
    int regNumberBackup = regNumber;


    for(int i = 0; i <= 7; i++)
    {
        binaryDigit[i] = regNumber % 2;
        regNumber = regNumber / 2;
    }


    int binaryNumber = binaryDigit[0] * pow(10, 7) + binaryDigit[1] * pow(10, 6) + binaryDigit[2] * pow(10, 5) + binaryDigit[3] * pow(10, 4) + binaryDigit[4] * pow(10, 3) + binaryDigit[5] * pow(10, 2) + binaryDigit[6] * pow(10, 1) + binaryDigit[7] * pow(10, 0);
    char binaryString[8];
    
    intToStr(binaryNumber, binaryString);
    int strSize = strlen(binaryString);
    
    if(regNumberBackup == 0)
    {
        printf("Your number in binary is: 0");
        exit(0);
    }


    if(regNumberBackup == 1)
    {
        binaryString[strSize - 7] = '\0';
    }
    else if(regNumberBackup > 1 && regNumberBackup <= 3)
    {
        binaryString[strSize - 6] = '\0';
    }
    else if(regNumberBackup > 3 && regNumberBackup <=7)
    {
        binaryString[strSize - 5] = '\0';
    }
    
    
    printf("Your number in binary is: %s", binaryString);
}


int main()
{
    int userInput;


    printf("// This will only convert numbers 0 - 255 to binary, any others will not work\n");
    printf("Enter a number: ");
    scanf("%d", &userInput);


    binaryConvert(userInput);
}

r/C_Programming • • 4d ago

Article Reducing undefined behavior in the C language

Thumbnail lwn.net
70 Upvotes

r/C_Programming • • 4d ago

Profiled our async C logger expecting mutex contention. 90% of caller-thread time was in vsnprintf. Moving formatting to the worker took a call from ~1.5 µs to ~70 ns

47 Upvotes

Our logger's caller-thread cost went from ~1.5 µs to ~70 ns, and I didn't touch a single call site.

I'll be honest: I was convinced the mutex was the problem. The logger already had a ring buffer, a worker thread, and hot-reloadable filters. It looked fast on paper. So I opened the flame graph expecting to see lock contention.
Instead, about ~90% of caller-thread CPU was sitting inside vsnprintf.

Every log call was formatting its message before enqueueing it. That's 900 ns to 3 µs per call, depending on the output. The fix came from NanoLog: don't format on the caller thread at all.

Now the caller just saves the format string pointer and packs the args into a tiny binary blob. The worker thread builds the string later. Cost per call: 30-80 ns, and no vsnprintf anywhere.

It wasn't free, though:
Format strings must be literals. A stack-built format string will dangle by the time the worker reads it.
Structs silently fall through to %p. I'm still not thrilled about that one.
%s args are copied at pack time and capped at 255 bytes.
For us, that was a good trade.

The bigger lesson for me was to profile before you optimize. I would have happily spent a week tuning a lock that wasn't the problem.

Has anyone run NanoLog-style encoding in production? I'm curious what pushed you there: latency, throughput, or tail behavior?


r/C_Programming • • 4d ago

Glibc posix 2024 incompatibility

6 Upvotes

I been coding some posix porable stuff and i tried to use pipe2 and dup3 which are considerd posix since 2024 (Issue 8) i defined _POSIX_C_SOURCE to 202405L and included unistd.h and gcc greated me with implicit declaration i looked at my local unistd.h and it had pipe2 and dup3 behind __USE_GNU which is just wrong so i checked offical source code latest branch and it had the same bug, Please if some of you guys have sourceware bugzilla account please report it, it is a big issue


r/C_Programming • • 3d ago

C++ vs C

0 Upvotes

What's the difference between C++ and C?

And what is Clang? Is the gcc compiler for c and c++?

Does C++ completely backward compatible with C?

C is procedural and C++ is object oriented as far as I know.

Is C++ more optimized and faster?

Tell me about the compiler - is clang and gcc the best compilers out there? are they open source?

Has anyone coded the CPP compiler?

Thanks,

Dennis


r/C_Programming • • 4d ago

Could not Compile

0 Upvotes

I used gcc to compile and run c file.

C prog file can be compile and run with no error, if the files are inside the same drive as gcc that is c: drive.

Program file inside the d: drive are not compile.

I just curious whether i made mistake or i need something to do.


r/C_Programming • • 6d ago

Question Why are so many C projects being rewritten in Rust?

438 Upvotes

I've noticed that more and more projects originally written in C are being rewritten in Rust, even when they seem to work perfectly fine. For example, there are efforts to rewrite some GNU utilities in rust, including basic command-line tools. I'm curious about why this is happening. Is memory safety the main reason, or are there other significant advantages to rust? If a program is already stable, reliable, and well-maintained in C, does rewriting it in rust really make sense? I'd like to understand what benefits justify the effort.


r/C_Programming • • 5d ago

Question What do I need to be proficient in C

53 Upvotes

Hi, I know the basics but I really don’t know how to continue learning C, I try to read code of many sources like linux kernel or other projects but I don’t understand them at least the majority of code with pointers and arrow operators…. I really like C and low level code.

Any advice is appreciated! Thanks.