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 • • 3d 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

Discussion 1 year With No AI

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

Question What are some neat TUI libraries ?

21 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!


r/C_Programming • • 1h ago

Which IDE would you recommend?

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

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

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

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

Thumbnail quuxplusone.github.io
45 Upvotes

r/C_Programming • • 1d ago

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

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

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

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

Fluent Interface in C - Look ma, no this!

Thumbnail
opensource.googleblog.com
53 Upvotes

r/C_Programming • • 2d 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 • • 3d 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

110 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 • • 3d ago

ISO C Chaining: Look ma, no this!

Thumbnail goo.gle
36 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 • • 3d ago

Question Library API Naming Conventions

21 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!


r/C_Programming • • 3d ago

Question Signal handlers, how to have them act differently (or the process) based on when the process receives the signal

2 Upvotes

Hello, everyone. I'm supposed to be doing a project for school (hence why I can't share the code), but I'll try to describe my problem to the best of my abilities.

My main parent process forks several children, who will execute 2 other programs, depending on the role assigned to them. Once the parent process receives a SIGALRM, it sends a SIGTERM to all its kids, and they, already having changed their signal handlers for SIGTERM, have to do whatever is specified in their signal handler.

Let's consider child A executes program A, and child B executes program B. These 2 processes have to communicate with each other through a series of msgsnd/msgrcv (we can only use System V IPCs in this project, so the msgops don't restart once interruped by a signal). A single process of type B will communicate with several processes of type A (but not with all at the same time: once its communication is finished with one, it goes on to the other). The last msgop A does, is a msgsnd and B does a msgrcv. I'd like to also add that, between the msgrcv and msgsnd on A's part, A is also supposed to go to sleep. A's almost entire program is in a while (it never terminates unless it receives the signal from its parent), whereas B terminates successfully once it's finished communicating with all the necessary A processes.

Whether B receives the SIGTERM signal or not, it has to modify sth in a shared memory section, but what it changes, depends on whether it has finished communicating with all the processes or not.

Ideally, I would like for B to terminate successfully, even if it receives SIGTERM, after having done all it had to do, and I thought of blocking SIGTERM with sigprocmask. That said, couldn't it still receive the signal between the mast msgrcv operation and sigprocmask? Is there any way whatsoever to make a set of instructions atomic?

I considered only having a sig_atomic_t volatile variable in the signal handler, which would increment if the the sign handler is executed, but then, not only would I have to continuously check in case it changed its value, but (and this could be me being wrong, please correct me if that's the case), B could still receive SIGTERM right after the condition of the variable being 0 is checked, and before the following instruction is executed (like a nanosleep - which I'd like to avoid if SIGTERM has been received - OR before a msgrcv, leaving B to wait for a message that will never come, because A could have received the same signal and will not be sending a message).

I thought of having the signal handler check a variable and act differently based on its value, but, again, maybe B receives the signal right before said variable's value changes. I also considered having an if where the conditions would be the variable==0 && msgrv(...)!=-1, but the variable can change after its value has been verified.

Disclaimer: we haven't studied sig_atomic_t volatile variables, so my knowledge might be lacking, although I did try to read up on them and research them. Also, the parent won't be deleting the IPCs until all kids have terminated.

Am I supposed to just hope for the best here and just proceed with sigprocmask? Is there another way I'm not seeing? Am I misunderstanding something? Any help offered is invaluable, so thank you in advance. I'm happy to answer any clarifying questions if I was unclear at all in the post.


r/C_Programming • • 5d ago

Question Generating random numbers in a library

14 Upvotes

Hello!

I'm making some library and i need random numbers for some functions. Libc srand(), rand() and random() modify global libc state, so i'd like to not use them.

What options do i have? Is there maybe any popular things for my case?


r/C_Programming • • 5d ago

Is my code better

19 Upvotes

I shared some code earlier, and got some criticism, as well as making improvements of my own

Is it better? And where does it still fall short?

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

#include <quiz.h>

#define CLEAR_SCREEN "\033[2J\033[H"

int main(void) {
  char buff[100];
  int invalid = 0;

  while (1) {
    fputs(CLEAR_SCREEN, stdout);

    puts("Pick a subject:");
    puts("1: Addition");
    puts("2: Subtraction");
    puts("3: Multiplication");
    puts("4: Division");
    puts("5: Mixed");

    if (invalid) {
      puts("Please enter valid input");
      invalid = 0;
    }

    puts("Pick a number 1-5, or use 'quit' or 'exit' to quit");

    if (fgets(buff, sizeof(buff), stdin) == NULL) {
      puts("Failed, exiting");
      return 1;
    }


    if (strcmp(buff, "quit\n") == 0 || strcmp(buff, "exit\n") == 0) {
      fputs(CLEAR_SCREEN, stdout);
      break;
    }

    if (strcmp(buff, "1\n") == 0) {
      add();
    } else if (strcmp(buff, "2\n") == 0) {
      sub();
    } else if (strcmp(buff, "3\n") == 0) {
      mul();
    } else if (strcmp(buff, "4\n") == 0) {
      divs();
    } else if (strcmp(buff, "5\n") == 0) {
      mix();
    } else {
      invalid = 1;
    }
  }

  return 0;
}

r/C_Programming • • 5d ago

Is my code bad?

21 Upvotes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

char buff[100];

void add(void);
void sub(void);
void mul(void);
void divs(void);
void mix(void);

int invalid = 0;
int input = 0;

int main(void) {
start:
  fputs("\033[2J\033[H", stdout);

  if (invalid) {
    puts("Please enter valid input");
  }

  invalid = 0;

  puts("Pick a subject:");
  puts("1: Addition");
  puts("2: Subtraction");
  puts("3: Multiplication");
  puts("4: Division");
  puts("5: Mixed");
  puts("Pick a number 1-5, or use 'quit' or 'exit' to leave the program");

  if (fgets(buff, sizeof(buff), stdin) == NULL) {
    puts("Failed, exiting");
    return 1;
  }


  if (strcmp(buff, "quit\n") == 0 || strcmp(buff, "exit\n") == 0) {
    fputs("\033[2J\033[H", stdout);
    return 0;
  } else if (strcmp(buff, "1\n") == 0) {
    input = 1;
  } else if (strcmp(buff, "2\n") == 0) {
    input = 2;
  } else if (strcmp(buff, "3\n") == 0) {
    input = 3;
  } else if (strcmp(buff, "4\n") == 0) {
    input = 4;
  } else if (strcmp(buff, "5\n") == 0) {
    input = 5;
  } else {
    invalid = 1;
    goto start;
  }

  switch(input) {
    case 1:
      add();
      goto start;
    case 2:
      sub();
      goto start;
    case 3:
      mul();
      goto start;
    case 4:
      divs();
      goto start;
    case 5:
      mix();
      goto start;
    default:
      goto start;
    }
}

void add(void) {
  puts("add");
  fgets(buff, sizeof(buff), stdin);
}
void sub(void) {
  puts("sub");
  fgets(buff, sizeof(buff), stdin);
}
void mul(void) {
  puts("mul");
  fgets(buff, sizeof(buff), stdin);
}
void divs(void) {
  puts("divs");
  fgets(buff, sizeof(buff), stdin);
}
void mix(void) {
  puts("mix");
  fgets(buff, sizeof(buff), stdin);
}

Is my code that bad?
For context this is a project I was doing to learn the C

Edit: Fixed formatting errors


r/C_Programming • • 4d ago

How can I pass c exam

0 Upvotes

I have a c exam tomorrow, I failed my internal exams, ik what im doin is dumb . Exam is on 50 and I need 15 to pass but I don’t know how to write programs, can I pass by studying theory