r/C_Programming 10h ago

Question The easiest UI library? (cross-platform)

13 Upvotes

Hello, I need to write a small emulator for a project. I want it to show RAM, registers, etc., while it's running a program step by step. Printing them out via printf is lame and won't look good.

Which is the absolute easiest graphics library for this purpose? I was suggested Newt, but it can't work under Windows.

Preferably, the library should have tutorials, examples, or at least full documentation.


r/C_Programming 3h ago

Learning C weekly megapost for 2026-07-22

9 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 13h ago

printf and char[] in C

7 Upvotes

Hello. Coming from C# world the thing about how char[] and printf works always made me confused. I understand that `printf` formats the string with arguments you provided and prints it out in terminal.

So, for example, if I have char name[] = "Micheal"; and I want to greet that person, I can just do printf("Hello, %s", name);. But if I want to do the same thing only using char[], I have to do multiple commands that make fell quite confused. So my 2 questions are:

  1. How printf simplifies this process? (without allocating memory and creating char with pointers)
  2. Why you can't just use + operator for char[], like you can in any other languages?

I have a feeling that this might be asked many times, but I still can't seem to find the answer I was looking for

Update: I'll list what I got so far from reading your comments: - char[] is an array to which you can't just simply add another array - If I want printf() behavior inside char[], I can use sprintf() - There's strcat() that is getting used for merging 2 strings together - Some people write libraries for faking string behaviors, some think it goes against principles of C?


r/C_Programming 14h ago

Question I am starting out on next project of simulating no-body problem. Need advice.

8 Upvotes

Hey there! In my last post, I was really excited after discovering ray tracing and the idea of implementing that thing in C. Now I am more curious and I want something that is physics/mathematics heavy and can be made in C. For this, I am thinking of moving towards simulating 2 body problem and then n body problem in C. I am not sure if this is the right path so I need advice for that.

Someone in my last post advised me to implement FXAA/MSAA in C from basic principles. I was excited but then, I asked chatgpt and it suggested that I first make something using graphics and then implement these algorithms for anti-aliasing. Any ideas are welcome.

Thank you! Have a great day for the help.


r/C_Programming 10h ago

A C subset that compiles faster than Tiny C Compiler - Cm1 (C minus 1 or C - 1) programming language

2 Upvotes

Hi everyone,

I'm working on a programming language that compiles a subset of C. It is called Cm1 (meaning C minus 1) and you can writing and running C codes directly on your browser at https://cp1-lang.org/cm1/editor.html in a fraction of a second.

Why is it faster to compile than Tiny C Compiler? It is because Tiny C Compiler is a true compiler creating native binaries whereas Cm1 is a bytecode interpreter allowing you to test, debug, edit code and recompile very quickly or even do hot reloading. Cm1 can be used as a scripting language for shell scripts and video games, but this just a small use case because in theory, you can run 90% of your ENTIRE video game or software C program through Cm1's bytecode interpreter and leave 10% to compiled C and reap the benefits of very fast compilation and hot reloading.

100% Cm1 codes are compilable by GCC and Clang but the reverse is not true since Cm1 is just a subset of C. Major features that are omitted are function pointers, structs/unions inside functions, nested structs/unions. This programming language is under heavy development and I want to know if this comes as interesting to some of you. I'll try to post again on this subreddit if I got to bind Raylib game library to Cm1, allowing people to write Raylib games directly on their browser (works offline).

I know that programs that are written in C compiles fast already and there's even an existing compiler that is very fast (Tiny C Compiler). However, I'm the developer of Cp1 programming language (cp1-lang.org), which is a language that "transpiles" to C, and I aim to upgrade Cp1 by targeting the Cm1 language then compile it to bytecode in one command instead of a separate step in Makefiles or build scripts. This will make Cp1 very fast to compile for debug builds.


r/C_Programming 7h ago

Learning how to send a 2 layer internet request

1 Upvotes

I was recently learning how to send msgs in different internet layers, and I write some examples from what google ai showed me.

Even tho I didn't fully understand what all the meaning of the full code. Running this program while wireshark is running, and seeing my own request is really cool.