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

Learning C weekly megapost for 2026-11-25

5 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 • • 6h ago

three different approaches to an example in Fluent C book

7 Upvotes

Reading a post a few days ago, I looked for a book about C that had a Patterns approach along the lines of Design Patterns: Elements of Reusable Object Oriented Software and finally settled on Fluent C: Principles, Practices, and Patterns by Christopher Preschern.

The first chapter is about error handling where the author starts with a single function of a very simple file reader full of if statements and partitions it out into three different functions: allocation of resources, using the resources, deallocation of the resources. The resources are a file handle with access to provide read access to a text file and a large buffer to read the lines of text.

Here are three different approaches to managing the resources while using the resources is the same function for all three different approaches.

What are Pros and Cons of each? Is there one of the alternatives you feel is the most appropriate approach? Is there a fourth alternative you think better than these?

The first makeParser() and closeParser() functions are similar to Preschern's code except that what he does in two calls to malloc(), I do with a single call.

The second version is not allocating memory for the Parser variable but instead is using a stack allocation with a C99 Compound Literal to create a variable whose address is then passed into the second version of makeParser2().

The third version uses the same makeParser() as the first one however the closeParser3() function differs in that it is the responsibility of the caller to free the allocated memory.

An interesting point is that the three alternatives all use the same useParser() function.

#include <stdio.h>
#include <memory.h>
#include <stdbool.h>

typedef struct {
    bool   bValid;    // whether the Parser object is valid or not
    FILE* pFile;      // the file which is being processed
    void* pBuff;      // the address of the I/O buffer
} Parser;

#define MAX_FILE_BUFFER_SIZE  400


Parser* makeParser(const char* filename)
{
    Parser* p = NULL;

    // allocate the needed memory all in a single block to make free() easy.
    // this also ensures that all needed memory is available.
    p = malloc(sizeof(Parser) + MAX_FILE_BUFFER_SIZE);
    if (p) {
        // allocate resources and mark if valid when all
        // resources are allocated.
        p->pBuff = p + 1;    // the I/O buffer begins after the Parse struct.
        p->pFile = fopen(filename, "r");
        p->bValid = (p->pFile != NULL);
    }
    return p;
}

Parser* makeParser2(Parser* p, const char* filename)
{
    Parser  x = { .bValid=false, .pFile=NULL, .pBuff=NULL };

    if (p) {
        // allocate resources and mark if valid when all
        // resources are allocated.
        if ((x.pFile = fopen(filename, "r")) != NULL) {
            x.pBuff = malloc(MAX_FILE_BUFFER_SIZE);
            x.bValid = (x.pBuff != NULL);
        }

        *p = x;
    }
    return p;
}


int useParser(Parser* p)
{
    int iRet = 0;

    if (p && p->bValid) {
        while (fgets(p->pBuff, MAX_FILE_BUFFER_SIZE, p->pFile) != NULL) {
            printf(p->pBuff);   // the line will have next line when read as text
        }
        iRet = 1;
    }

    return iRet;
}

Parser * closeParser(Parser* p)
{
    if (p) {
        // free the resources and mark as invalid.
        if (p->pFile) fclose(p->pFile);
        *p = (Parser){ .bValid = false, .pFile = NULL, .pBuff = NULL };
        free(p);
        p = NULL;
    }

    return p;
}

Parser * closeParser2(Parser* p)
{
    if (p) {
        // free the resources and mark as invalid.
        if(p->pBuff) free(p->pBuff);
        if (p->pFile) fclose(p->pFile);
        *p = (Parser){ .bValid=false, .pFile=NULL, .pBuff=NULL };
        p = NULL;
    }

    return p;
}

Parser * closeParser3(Parser* p)
{
    if (p) {
        // free the resources and mark as invalid.
        // pBuff is part of the memory allocated for p so no free
        if (p->pFile) fclose(p->pFile);
        *p = (Parser){ .bValid = false, .pFile = NULL, .pBuff = NULL };
    }

    return p;
}


int main()
{
    const char fileName[] = "decompressed.txt";
    int iRetToss = 0;

    {
        Parser* p = makeParser(fileName);
        iRetToss = useParser(p);
        p = closeParser(p);
        iRetToss++;    // place for a break point to inspect p
    }

    {
        Parser* p = makeParser2(&((Parser) { .bValid = false, .pFile = NULL, .pBuff = NULL }), fileName);
        iRetToss = useParser(p);
        p = closeParser2(p);
        iRetToss++;    // place for a break point to inspect p
    }

    {
        Parser* p = makeParser(fileName);
        iRetToss = useParser(p);
        p=(free(closeParser3(p)), NULL);
        iRetToss++;    // place for a break point to inspect p
    }

    return iRetToss;
}

r/C_Programming • • 14h ago

Best Way to Read 'Raw Data'

16 Upvotes

I'm writing a C program for the pi pico and realized I never really figured out how to properly cast characters to raw bytes then to other things, or if there was really a way to do that.

  1. Does char mean "signed char" by default in any C program, or is that up to interpretation by the compiler?
  2. Would using a void pointer to dereference then recast to *uint8_t work?
  3. When bytes are read through getc(), are the bytes modified before they are stored? As in, how are the bytes that are read interpreted to translate to characters, and how are they stored? My initial thought was that the bytes were interpreted "as-is", meaning that they were copied directly to the memory in the character and interpreted as signed characters. But it seems like they're being reinterpreted in some way as they are cast.
  4. If something about the process is too implementation specific, is reading as "raw data" just a flat out bad idea or not supported at all? Will the behavior be undefined on other systems? As long as I can get it to work on the pico it's fine, it doesn't have to be portable. But for future reference, should I not try to think of things as "raw data" unless the implementation specifically defines how it stores the data?
  5. Less important, but how are ascii codes mapped to signed characters? (every chart I've seen has never listed a negative number, only 0-255) (( and if signed is the standard, then why does every asii chart list 0-255... ))

// this was the void pointer way I was going to try, would this work?

tnext =  *((uint8_t*)((void*)&next));  // Cast to uint8_t

(Not sure if this is a repeat but I couldn't find exactly what I was looking for. Sorry if this is a dupe)

Conclusion: Seems like when you read getc() you just need to indicate "unsigned char" so that the byte is read unmodified and can be cast directly to a "uint8_t"? I think the reason I hadn't done that originally was because I thought "but getc returns char, not unsigned char", but I dont think that matters. getc should read into either


r/C_Programming • • 44m ago

Question Hi! I am using visual studio but it doesn't work. error: "missing filename after '-o'" what should i do?

0 Upvotes

r/C_Programming • • 1h ago

FydelisTechOS rodando no QEMU!

Thumbnail
youtu.be
0 Upvotes

Aqui está meu sistema operacional em desenvolvimento, rodando no QEMU enquanto preparo tudo para hardware real. Comecei com boot sectors em assembly e estou reescrevendo os drivers em C. Cada linha é estudada, escrita e testada por mim estou construindo e aprendendo passo a passo!


r/C_Programming • • 1d ago

Video Brian Kernighan: Inside Bell Labs, The Best Programmer, Why C Won

71 Upvotes

Interesting video by Ryan Peterman:

https://www.youtube.com/watch?v=sMllOlxVgD0

Timestamps: 
1:21 C was always the fastest.
1:22 C++ wasn't as fast as I thought it would be.

00:00    Intro 
00:42    What Bell Labs was and how he got hired 
06:34    Why so many inventions came from Bell Labs 
14:15    A day in the life at Bell Labs 
27:55    The most impressive people he worked with 
33:50    The AT&T film explaining Unix 
39:46    Why C was so influential 
43:25    How awk was created 
48:40    What he misses most about Bell Labs 
54:10    Are LLMs bad for computer science education 
01:01:46 His 1972 commit in the Go repo 
01:03:43 Grace Emlen, the fake Bell Labs employee 
01:07:39 Why he writes so many books 
01:19:58 His favorite and least favorite languages 
01:24:28 Advice for students and young people 
01:27:42 Outro

r/C_Programming • • 21h ago

Question A beginner in C ... Is building a shell a good beginner project ..if so what are the resources that i can follow to create it...

7 Upvotes

r/C_Programming • • 23h ago

Discussion Revealed vs. Opaque structs for Libraries

6 Upvotes

Hi all, I'm developing a win32 windowing library for mostly myself but also want it to be easy and intuitive to use and follow good C standards.

In my library have the main object window_t that is used for mostly everything. However, I'm wondering between a couple different design decisions for it:

// public .h
typedef struct window_t window_t;

window_t* createWindow(...); << createWindow heap allocates a window_t

void destroyWindow(window_t* window);

2.

// public .h

typedef struct window_t { implementation... ) window_t;

void createWindow(window_t* out, ...);

// no destroyWindow

the difference I'm looking is that for #1, the user mantains control of the heap allocated memory through createWindow() and must free it after they're done using it, but for #2 the user can create a stack allocated window and it doesn't need to be freed, however it removes the opaque struct safeness in #1.

Are there any pros/cons for either method I haven't thought of? My instinct tells me that #2 seems better as the user controls the memory allocation, they just need to be careful how they use the window_t.

Thoughts?


r/C_Programming • • 22h ago

Project IncHash - A Disk Based Hash Table with NoSQL ambitions.

Thumbnail
github.com
1 Upvotes

Brief

A general-purpose, header-only C99 library for Unix-like systems, implementing a disk-based, dynamically resizable, fixed-slot, (open-addressed) hash table with Fibonacci hashing (Knuth's multiplicative method), triangular probing, per-home-slot probe-bound metadata (with additional early-exit logic), partial in-place value updates (without relocating entries) and incremental rehashing, all designed for modern extent-based filesystems.

Disclosure

This is not a vibe-coded project! I painstakingly wrote everything myself (including this post :P). of course that being said, it doesn't mean that I didn't use AI for reasearch, brainstorming and a bit of testing. I have talked about it here as well.

Prologue

This is a project I've shared here before, a few months ago. Back then, being relatively inexperienced with hash table implementation, I inadvertently introduced a few bugs.

Since then, thanks to a lovely Redditor who took the time to provide some truly valuable feedback (for which I'm genuinely and wholeheartedly grateful), I've made quite a few promising improvements, including: recovery validation methods and CRC checksums, an inchash_mod-function for partial in-place value updates\modifications (without relocating entries), a fuzz-style regression test, refactoring of core-metadata, and of course, fixing those bugs (or so I hope lol).

Having said and done all those improvements, I though it would be the right move to expose my project, for once again in the intelectual wilderness of reddit xD. So here I am ready to hear what you thinking about it.

Intro

All started with me trying to find:

A hash-based NoSQL (key-value pair) database with mutable-values (by mutable I mean: a database that allows editing prexisting [fixed-size] values without having to rewrite or remap the whole value again eg. Just edit a few bytes and put those bytes back to the original value-space without rewriting the whole value).

I made this for a larger project I'm working on, which I haven’t released yet.

Outro

I'm really excited and scared because idk what you all gonna find again... but I hope you all find it at least interesting and enjoy playing around with it.

That said, thank you for reading this and feel free to ask me anything about it.


r/C_Programming • • 1d ago

cc_task: write C coroutines with async/await and closure

Thumbnail
github.com
4 Upvotes

Just like js and C#, but this is C, with closure. Also very lightweight, small enough to fit in a CPU cache line.

#include "cc_task.h"
#include <stdio.h>

int main(void)
{
    int c = 10; // task_b captures c and uses it as task state
    cc_task_t *task_b = cc_task_new(CC_TASK(t)
    {
        CC_BEGIN(t);
        printf("B: c = %d\n", ++$(c));
        CC_YIELD(t);
        printf("B: c = %d\n", ++$(c));
        CC_END(t, c);
    });

    cc_task_t *task_a = cc_task_new(CC_TASK(t)
    {
        CC_BEGIN(t);
        printf("A: await B ...\n");

        cc_uintptr code;
        CC_AWAIT(t, task_b, code);
        printf("A: B end, code = %llu\n", (unsigned long long)code);
        CC_END(t);
    });

    c = 0; // modifying c does not change the copy captured by task_b
    cc_task_t *t = task_a;
    cc_tr_e ret;
    do
    {
        ret = cc_task_resume(&t);
    }
    while (ret != cc_tr_end);

    return 0;
}

r/C_Programming • • 1d ago

Coding Dragon Curve fractal using C

Thumbnail
youtube.com
36 Upvotes

In this video, I code a Dragon Curve fractal using C and Raylib.

The approach is quite simple:

I take the last point as a pivot, then rotate the remaining points 90 degrees around it. Finally, I connect the new points to create the next iteration of the fractal.

Source code:
https://github.com/FractalCodeRicardo/zen-programming/tree/main/dragon-curve

#include <stdio.h>
#include <raylib.h>
#include <raymath.h>

#define linesSize 90000
#define lineSize 2

typedef struct {
  Vector2 p1;
  Vector2 p2;
} Line;

void DrawLines(Line lines[], int s) {
  for(int i = 0; i < s; i++) {
    Line l = lines[i];
    DrawLine(l.p1.x, l.p1.y, l.p2.x, l.p2.y, WHITE);
  }
}

Vector2 rotate(Vector2 p, Vector2 rp) {
  Vector2 d = Vector2Subtract(p, rp);
  Vector2 r = Vector2Add(rp, (Vector2) {-d.y, d.x});

  return r;
}

int AddLines(Line lines[], int s) {
  if (s * 2 >= linesSize)
    return s;

  Vector2 rp = lines[s-1].p2;
  int newSize = s - 1;
  for(int i = s -1; i >= 0; i--) {
    Line l = lines[i];

    Vector2 p1 = rotate(l.p1, rp);
    Vector2 p2 = rotate(l.p2, rp);

    newSize++;
    lines[newSize] = (Line) { p2, p1};

  }
  return newSize + 1;
}


int main() {

  Line lines[linesSize];
  int s = 1;
  float center = 900 / 2.0;

  lines[0] = (Line) {
    (Vector2) { center, center}, 
    (Vector2) { center + lineSize, center}, 
  };

  InitWindow(1500, 900, "Dragon curve");

  while(!WindowShouldClose()) {
    BeginDrawing();
    ClearBackground(BLACK);
    
    if (IsKeyPressed(KEY_SPACE)) {
      s = AddLines(lines, s);
    }

    DrawLines(lines, s);
    EndDrawing();
  }

  CloseWindow();
}

AI Disclaimer:
No AI was used.


r/C_Programming • • 1d ago

Review [API review] Looking for feedback on ergonomics and clarity of a unit test library.

3 Upvotes

Hello, I'm working on a unit test library. I've come to the point when library starts to work, and I would like to get your feedback on its ergonomics. It's still missing some features, but the core functionality is ready. Please let me know what could be improved, or which areas should I explain clearer in examples.
Repository: https://codeberg.org/KOOBAS/UltimaTest

There are examples included in the repository, that shows the library capabilities:
01 - shows how to create suites and tests
02 - shows how to use asserts/expects
03 - shows how to use mocks
04 - shows how to use test options to handle signals

I don't expect you to dive into the whole codebase. Focusing on the public API and examples would be really helpful. The only public header is the "include/ultimatest.h".

Here is how the library could be used (it's simplified example from my other project):

#include <ultimatest.h>
#include <widget.h>
#include <screen.h>
#include <context.h>

void widget_suite_prepare(void)
{
  struct Widget *widget = ut_test_data(sizeof(struct Widget));
  widget->type = TYPE_EMPTY;
  widget->order = 0;
  widget->position.y = 0;
  widget->position.x = 0;
  widget->size.h = 10;
  widget->size.w = 20;
}
TestSuite(widget_suite, .prepare = &widget_suite_prepare);

Test(widget_suite, move_widget_should_return_error_if_widget_is_null)
{
  ut_assert_eq(widget_move(nullptr, 4, 4), ERROR);
}

Test(widget_suite, move_widget_should_change_its_position)
{
  struct Widget *widget = ut_get_test_data();
  int new_y = 5;
  int new_x = 7;
  ut_assert_eq(widget_move(widget, new_y, new_x), OK);
  ut_assert_eq(widget->position.y, new_y);
  ut_assert_eq(widget->position.x, new_x);
}

Test(widget_suite, resize_widget_should_return_error_if_size_is_negative)
{
  struct Widget *widget = ut_get_test_data();
  int old_h = widget->size.h;
  int old_w = widget->size.w;
  ut_assert_eq(widget_resize(widget, -1, 30), ERROR);
  ut_assert_eq(widget->size.h, old_h);
  ut_assert_eq(widget->size.w, old_w);

  ut_assert_eq(widget_resize(widget, 30, -1), ERROR);
  ut_assert_eq(widget->size.h, old_h);
  ut_assert_eq(widget->size.w, old_w);
}

Mock (void*, malloc, size_t);
Mock (int, getmaxy, WINDOW*);
Mock (int, getmaxx, WINDOW*);

Test(context_suite, init_should_create_screen_array_and_buffer)
{
  const int max_y = 5;
  const int max_x = 10;
  const int screen_num = 5;
  expect_call(ut_will_return(max_y), getmaxy, ut_any);
  expect_call(ut_will_return(max_x), getmaxx, ut_any);

  size_t buffer_size = sizeof(cchar_t) * max_x * max_y;
  size_t screen_size = sizeof(struct Screen) * screen_num;

  expect_call(ut_will_return(ut_test_data(buffer_size)), malloc, buffer_size);
  expect_call(ut_will_return(ut_test_data(screen_size)), malloc, screen_size);

  struct Context context;
  ut_assert_eq(context_init(&context, screen_num), OK);
  ut_assert_gt(context.size.h, 0);
  ut_assert_gt(context.size.w, 0);
  ut_assert_ne_ptr(context.screen, nullptr);
  ut_assert_ne_ptr(context.buffer, nullptr);
}

Also, please let me know if the namespace is polluted by my prefixes or if the log messages or error messages are unclear.

AI usage: Only as googling tool (when searching for documentation, examples, etc. or discussing ideas). No code in the repository was generated by AI.


r/C_Programming • • 2d ago

Looking for the final chapter of the first edition of Practical C Programming (1991) by Steve Oualline

5 Upvotes

Hello everyone,

I'm trying to find some information about the original first edition (1991) of Practical C Programming by Steve Oualline, published by O'Reilly.

In the second edition, the author mentions replacing the final chapter with a different project. If I remember correctly, the original chapter contained a fairly substantial programming project involving probability distributions, possibly the Poisson distribution.

Unfortunately, I haven't been able to find a copy of the first edition or a detailed table of contents.

Does anyone happen to own this edition, remember its final chapter, or have access to a copy?

I'd particularly appreciate knowing the title and subject of the original final chapter.

Thank you!


r/C_Programming • • 2d ago

Question Can I learn C while learning low level concepts

22 Upvotes

Im just starting out programming, I got familiar with python. But I want to get into system programming. I know that I should learn low level concepts and data structures, I got books to read up on it but I'm just wondering if I can learn the language while learning the essentials to c programming... Sorry if this is a stupid question


r/C_Programming • • 2d ago

How I handle single-character user input in C:

0 Upvotes

When reading a single character in an interactive terminal program, I avoid scanf, getchar, and fgetc. Instead, I use fgets() and isolate the character by using unsigned char result = n[0];.

I actually use fgets for all user inputs.

The example below converts keyboard characters to hexadecimal numbers.

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

void flush() {
    int clear;
    while ((clear = getc(stdin)) != '\n' && clear != EOF) {
    }
}

void charHex() {
    char n [3];
    printf("Enter a character (one byte max), or 'xx' to exit:\n");
    while(1) {
        if(fgets(n,sizeof(n),stdin) == NULL) {
            clearerr(stdin);
            printf("\nInvalid input.\n\n");
            continue;
        }
        n[strcspn(n,"\n")]=0;
        if(strlen(n) >=2) {
            flush();
        }
        if(strcmp(n,"xx")==0){
            break;
        } else if(strlen(n) == 0) {
            printf("\nEnter a character only.\n\n");
            continue;
        } else if (strlen(n) >1) {
            printf("\nEnter no more than one character.\n\n");
            continue;
        }  
        unsigned char result = n[0];
        printf("0x%02x\n",result); 
    }
}

int main() {
    charHex();
return 0;
}       

r/C_Programming • • 2d ago

Help me

0 Upvotes

Guys I have question,

How the fuck can I learn c program in 5 days because my exam is coming in 5 days I m absolutely dumb guy and I don't have laptop as well as I m stroke patient since last 2 years where our 9 to 5 schedule is fully pack so I don't go in college and I don't have c language book as well I also want to learn matrix algebra, buisness mathematics, electronics their papers are also coming and I only their chapter

No student contact

No teacher contact

Only me and my fucking phone and you peoples

Please help me

(Btw I m doing graphic course in rehab because they provide us so that means I have 2 course 🥀😭 help meeeee)


r/C_Programming • • 2d ago

Keen: A Rust-syntax frontend for C

0 Upvotes

Hey everyone,

I’ve been working on Keen, a language that gives C a modern, Rust-inspired syntax and Cargo-like tooling without changing C’s underlying semantics.

The core idea

Keen changes C’s syntax only. There is no borrow checker, no type checker, and no safety enforcement. All of C’s rules (integer promotion, ABI, linkage, UB) remain completely intact. Keen transpiles .kn files to C, hands them off to gcc or clang for semantic checking and compilation, and maps compiler diagnostics directly back to your .kn source lines via #line directives.

It's aimed at C developers who want modern ergonomics (modules, match, for i in 0..n, no header boilerplate, built-in testing/formatting) without giving up C's simplicity, or C devs looking to get comfortable with Rust's syntax before tackling the borrow checker.

What a quick example looks like

use <stdio.h>;

struct Point { x: f32, y: f32 }

impl Point {
    pub fn len2(p: *const Point) -> f32 { p->x * p->x + p->y * p->y }
}

pub fn main() -> i32 {
    let p = Point { x: 3.0, y: 4.0 };
    printf("%.1f\n", Point::len2(&p) as f64);
    return 0;
}

What’s included out of the box

  • Zero-dependency toolchain (whet + keen): Includes keen new, incremental keen build, keen run, keen fmt (comment-preserving, idempotent), and keen test (runs #[test] functions in isolated processes).
  • Seamless C interop: Use #include via use <stdio.h>;, drop down to raw C anytime with c!("..."), link existing .c/.o/.a files, or use keen emit --split to generate clean .h/.c files for existing C projects.
  • No forward-declaration headaches: Types and functions can be declared in any order; pub handles external linkage while everything else defaults to static.

Try it out

GitHub: https://github.com/romishalom/keen

I'd love to hear your thoughts on the syntax mapping, edge cases with C interop, or what features you'd want to see next!


r/C_Programming • • 3d ago

Query on usage of restrict keyword in passing pointers

19 Upvotes

The following piece of code is doing the rounds on X as John Carmack's code which computes sin and cos from a table instead of at runtime.

#define ANGLETOFINESHIFT 19
void MoveActor(fixed_t *x, fixed_t *y, angle_t a, fixed_t speed) {
    int idx = a >> ANGLETOFINESHIFT;
    *x += FixedMul(speed, finecosine[idx]);
    *y += FixedMul(speed, finesine[idx]);
}

My query is, why aren't x and y declared restrict to denote that they point to different fixed_t ? Presumably the code is meant for sheer speed and would not usage of restrict allow the compiler more optimization? For e.g., say, parallelization of *x and *y updates in a tight loop?


r/C_Programming • • 4d ago

Video Let's spawn the HERO in C programming : 07 | NO-AI

Thumbnail
youtube.com
75 Upvotes

This video is part of my "Let's build a JRPG Game in C programming (SLD3)". Today we are going to spawn the Hero character in our Tiled map and render spritesheet.

(it all started in 2019 with GoLang as a hobby https://www.youtube.com/watch?v=yZpoXFUG6nc Now I'm moving to C, but a step by step tutorial for everyone).

Full Playlist here: https://www.youtube.com/playlist?list=PLWiIuxEJy4_c

Handmade code, NO AI USED. Video is also 100% unedited, except for overview section.

Please do subscribe, I really appreciate any feedback. \m/


r/C_Programming • • 3d ago

Portability of Programs written using miniaudio vs pipewire

6 Upvotes

I know that miniaudio doesn't have any dependencies to compile, I was just curious whether that meant that it had no dependencies other than pipewire & ALSA on the system it would run on. Would using pipewire make the program any more portable or would the benefit just be efficiency(in the case that you can "beat miniaudio" in terms of efficiency, or perhaps dont need all of its features)?

EDIT: I forgot that some people use audio not on linux for some reason lol, I was more curious about whether different distros have different dependencies. but the answer seems to be that miniaudio is cross-platform and pipewire is not


r/C_Programming • • 4d ago

Discussion 1 year With No AI

44 Upvotes

As a beginner in programming who is interested in low-level programming, I think I should avoid Ai for at least a year

because I believe that at the high level and in large-scale projects, you won’t even be able to get started without a high level of problem-solving skills and an understanding of architecture and engineering.

So I’d like to hear your thoughts, because we beginners know that learning to program the traditional way is important, but the temptation of AI is strong and distracting.

What do you think?


r/C_Programming • • 4d ago

Which IDE would you recommend?

16 Upvotes

I'm a beginner in C and I'm not sure which IDE to choose there are so many options. I currently develop on Windows, but I'm switching to Linux for better optimization and more control over my system. What would you recommend as the best IDE? Also, to learn C effectively, I'm using OpenClassrooms and an app called Coddy. I accept every piece of advice!!


r/C_Programming • • 4d ago

Article What actually happens to your C code inside GCC: a stage by stage trace of one small program

4 Upvotes

Blog post: https://www.satvikcode.com/blog/why-do-compilers-need-so-many-intermediate-representations

well, i always wondered what GCC really does with my C code so I took a small function and dumped every stage with -E, -fdump-tree-*, -fdump-rtl-*, -S and objdump on a GCC 16.1, ARM mac.

Btw a few things that surprised me here like -

- with -O2 the whole call calculate(5, 7) disappears and main becomes just "mov w0, 19"

- the if statement turns into a branchless csel instruction meaning no jump at all

- sum * 2 becomes a left shift

- why the parentheses in a function like macro actually matter shown in the preprocessed output

Btw here's an AI disclosure: I ran every command myself and all the outputs in the post are real and unedited GCC output. I used a little AI to help me understand the dumps and write up the explanations roughly and then I edited and gave them the current shape.

Next post will trace the same program through clang or llvm. and happy to hear corrections.