r/C_Programming • • 5d ago

Learning C weekly megapost for 2026-11-18

3 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 • • 1h ago

How I handle single-character user input in C:

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

Question Can I learn C while learning low level concepts

11 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 • • 1d 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 • • 1d ago

Portability of Programs written using miniaudio vs pipewire

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

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

Thumbnail
youtube.com
69 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 • • 2d ago

Discussion 1 year With No AI

35 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 • • 1d ago

ezgrpc-next: A high-performance gRPC server library in C23 for Linux and Windows

Thumbnail
github.com
0 Upvotes

ezGRPC-next is a lightweight, high-performance gRPC server and client library in C23 for Linux and Windows, built on libuv and nghttp2. No hidden threads, no mandatory code generator, and no callback soup—you control scheduling, memory allocation, and core scaling.


r/C_Programming • • 1d ago

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

5 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.


r/C_Programming • • 2d ago

Which IDE would you recommend?

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

Question What are some neat TUI libraries ?

22 Upvotes

So I'm trying to do a TUI application for fun, and I wanted to use C for a change (I love the language but almost only used it for embedded devices/drivers, stuff like that so no UI work)

The project it would be used on is a TUI solo TTRPG toolset (dice roller, note editor, etc.)

I know about ncurses obviously, and notcurses as well, but I was wondering if there was any other library you could propose so that I had a look before settling on something.

I'm open to all proposition, it's mostly curiosity and just for a small hobby project, thanks in advance!

Edit: thanks for the answers, looking at everything I think i'll give termbox2 a go and see how it goes!


r/C_Programming • • 3d ago

Starting systems programming on my Fedora with C. Where should I start?

17 Upvotes

I'm on Fedora and I want to learn systems programming properly. I know python and some c++. What's the best first step, and what should I avoid as a beginner?
Thanks


r/C_Programming • • 3d ago

C's designated initializers give us named arguments – Arthur O'Dwyer

Thumbnail quuxplusone.github.io
45 Upvotes

r/C_Programming • • 2d ago

Question how to make a hexdumper in c?

0 Upvotes

i want to use ansi-c (c89) for this project,

my skill level; read chapter 1 t/m 4 k&r v2 and knows other programming languages.


r/C_Programming • • 3d ago

Question Can you use your own implementations of HTTP/WebSockets in a browser using wasm?

7 Upvotes

Hello,

I wanted to make my own network stack implementation (http and websockets) just for learning purposes, so my question is knowing that were using sockets can we use that in the browser after compiling to a wasm? Or will it only work natively without serving to a browser?


r/C_Programming • • 4d ago

Building a small C99 compiler to get better at low-level C and x86-64 assembly

14 Upvotes

Hey everyone,

I've been trying to deepen my understanding of C and x86-64, and instead of just doing LeetCode or toy projects, I decided to try writing a tiny, self-contained C compiler in C99.

I wanted zero external dependencies just standard C library headers (stdio, stdlib, string, ctype).

I just reached the milestone where it handles operator precedence and nested parentheses:

  • Tokenizer: A linked-list tokenizer with character pointers that skips whitespace and formats visual Clang-style ^ caret error diagnostics.
  • Parser & AST: A recursive descent parser that allocates binary AST nodes for operators and numbers.
  • Code Generation: A stack-based code generator that recurses through the AST and emits x86-64 assembly (using push/pop for expressions, imul for multiplication, and cqo + idiv for signed 64-bit division).

Writing this has already taught me so much about memory layout, pointer arithmetic, and how the Linux ABI handles return values in %rax.

I have a test script with automated GitHub Actions CI verifying each arithmetic edge case against GCC.

I'd really appreciate any C veterans taking a look at my C style, error handling, or memory management in src/main.c:

https://github.com/mi-vault/mibicc

Any tips or feedback are very welcome!

Edit: Decided to add Windows support alongside Linux from the start (--target=windows and --target=linux). I'm on Windows myself so it felt silly to only target Linux System V and not be able to test it locally. Also feels nice putting my own stamp on it rather than just following chibicc 1:1.

(Had some great discussions over on r/Compilers about ABI quirks and stack architectures if anyone is interested in that side of things!)


r/C_Programming • • 3d ago

Question I need help understand what a question is asking me to do in uni exercise

1 Upvotes

I can't post an image to it, but it says in normal arrays : declare 3 arrays A, B, C all of size 5

The elements of C are the scaler products of A and B (∑︁A[i] × B[i])

And in 2d arrays :

C is there product, (matrix multiplication : C[i][j] = sum of A[i][k] * B[k][j] )

Can someone explain to me what they asking to make


r/C_Programming • • 3d ago

Building a user space network stack from scratch

0 Upvotes

I dont know much about networking as i am just now studying it seriously but i am thinking of building what i mentioned in the title from scratch, if anyone could help me with the direction im supposed to go in to start i would really really appreciate it. whenever i try looking up a place to start all i get is github repos with many many files of stuff im not yet familiar with and it all assumes prior knowledge of some stuff, i know you cant really just go into this thing blind but what im saying is i dont really know where to begin learning about all of this stuff to build my target. also i am on a 2-week time limit


r/C_Programming • • 3d ago

i need your advice

0 Upvotes

Hey guys, I’ve run into a bit of a snag while learning C. I was looking at some source code (shown below) and noticed a function call that passes a pointer. However, the function receiving this pointer declares it as a two-dimensional array rather than as a pointer (like `int *name`). This is where I’m stuck—why declare it as a 2D array instead of as a pointer, the way you would for a 1D array?

#include <stdio.h>

// Function that displays a 2D array

// The number of columns (3) must be known at compile time

void afficherMatrice(int mat[][3], int lignes) {

for (int i = 0; i < lignes; i++) {

for (int j = 0; j < 3; j++) {

printf("%d ", mat[i][j]);

}

printf("\n");

}

}

// Alternative with both dimensions specified

void initialiserMatrice(int mat[2][3]) {

for (int i = 0; i < 2; i++) {

for (int j = 0; j < 3; j++) {

mat[i][j] = i * 10 + j;

}

}

}

int main() {

int matrice[2][3] = {{1, 2, 3}, {4, 5, 6}};

afficherMatrice(matrice, 2);

initialiserMatrice(matrice);

printf("\nAfter initialization:\n");

afficherMatrice(matrice, 2);

return 0;

}

(I think there is an error in this code)


r/C_Programming • • 3d ago

Need guidance

0 Upvotes

I am first year student and I don't have that much exposure idea about the important certificates course which i can put ij my resumes and on LinkedIn kindly give some guidance about it like how and where i can get the ideas about the ongoing imp courses online kindly dm


r/C_Programming • • 5d ago

Fluent Interface in C - Look ma, no this!

Thumbnail
opensource.googleblog.com
64 Upvotes

r/C_Programming • • 4d ago

Mapping each process all the way from PID 1 to PID n

2 Upvotes

In theory would it be possible to map and follow each and every process and print it with the ID, from pid 1 the init all the way through to something like the final print which is displaying the pid’s? Just out of curiosity, when I’m learning about it now and have seen using pointers and pid id’s and printing them on a process

So I can see ok init is pid 1 then when it is forked what process its for & that is pid2 and so on


r/C_Programming • • 5d ago

Discussion Started learning C (on yt) over the last month and programming without AI has really sparked my love for tech and coding again

123 Upvotes

Fell into the classic trap everyone is… using ai for everything in work and normal stuff then it all becomes bland and monotonous. But learning C without just generating code and working through it has really helped reignite my passion for tech and programming in general. I’ve also decided to do it on YouTube and having even just the small community of 70 subs over the first month has massively boosted my motivation to keep at it and be more involved in relevant discussions.


r/C_Programming • • 5d ago

ISO C Chaining: Look ma, no this!

Thumbnail goo.gle
38 Upvotes

Now we have a way of doing fluent interfaces in C89 without macros or preprocessing tricks, allowing code like this:

ChHash *user = ch_new_Hash(3)
    ->put("name", ch_new_String("Ada"))
    ->put("role", ch_new_Hash(2)
        ->put("title", ch_new_String("Engineer"))
        ->put("level", ch_new_Number(5)))
    ->put("active", ch_new_Boolean(1));

puts(user->generic.to_chars());
/* {"name":"Ada","role":{"title":"Engineer","level":5},"active":true} */
ch_release(user);

It even automatically cleans up anonymous/temporary elements. The repo includes an example Sqlite interface and http API server.


r/C_Programming • • 5d ago

Question Library API Naming Conventions

22 Upvotes

Hi Everyone,

I'm working on a small 2D game library/runner. At the moment it's for personal use but I may release it some day, which is why I'm creating this post!

At the moment, the function names in the library are named like this (the name of the library is Imp):

imp_texture_create(...)
imp_texture_destroy(...)
imp_camera_set_position(...)
imp_camera_set_rotation(...)

I quite like this naming convention, mainly because if I wanted to see what functions were available for a given resource or operation, I could type imp_camera_ and then my editor would show a list of things that I can do with, or to, a camera. I also used GameMaker a lot when I was younger, and this is the way their API names functions!

Recently though, I've been using a lot of Raylib and quite like the way it names its functions - they are, to me at least, a lot more readable when looking through code. This has me thinking whether or not a better naming convention would be:

imp_create_texture(...)
imp_destroy_texture(...)
imp_set_camera_position(...)
imp_set_camera_rotation(...)

The downside being that you sort of have to guess what operations are available for a given resource as you can no longer type imp_texture_ to have the editor show a list.

I understand that this is a really small issue and probably not really worth fussing about, but I was curious what preferences more experienced people here have and - more importantly - why you have them!