r/cprogramming • • 15h ago

Small CLI tool for extracting video fragments from RTSP archived streams

Thumbnail
github.com
3 Upvotes

Hello, community! I am currently learning how to manipulate buffers, bytes and strings in C and I created this tool (mostly for myself) to better understand RTSP network protocol. I know similar tools exist but this one have very few settings so should be easier to use when all you need is to exract part of the video. It would be nice if someone take a look at the code and give me some feedback regrading my coding style and the quality of code. I think I used relatively efficient way to parse bytes coming from the network but I might be wrong. Also this tool aims to be zero allocation one so if it is not please let me know.

P.S. Since this a project for self-educating, no AI tools were used during development, README is written by myself with terrible English.


r/cprogramming • • 1d ago

How to get better at well structured/conventional code in C

13 Upvotes

Hello all. I used to write C a lot but honestly over the past few years I haven’t used much if any since I was using C++ a lot, mainly for computer graphics. I ended up going very deep in C++ and feel as though I can confidently write a well structured program, as I have a game engine and a raytracer.

However, I’ve been trying to get back into C as I am working on a Gameboy Emulator in C and trying to get my low level systems portfolio up since I really enjoy that as well and have forsaken it in lieu of graphics. I also realized it’s prob not gonna be easy to get a job in graphics until I get a PhD, and yet embedded is in a much better spot, so with it being something I like as well, I find it more beneficial right now while looking for an embedded job to write programs in C for my portfolio and just to learn (and to have fun).

Anyways, I am running into some issues I didn’t have before and I think it is because I am trying too hard to write things like I did in C++. Using the same naming conventions, file organization structures, splitting of functions and modules to create deeper abstractions, etc.

And yet even throughout all of that, I seem to be ending up with much messier and harder to manage code in my Gameboy Emulator that in all honesty, I have no idea what I’m doing. I’ve gotten decently far on it, wirh the entire instruction set being implemented and interrupts (somewhat) working, but it is becoming much harder to manage than it seemed wirh C++.

Is there any advice or resources (I prefer more comprehensive books but articles and YouTube videos are good too) that you can give me on just getting more comfortable with writing good, well structured C programs?


r/cprogramming • • 23h ago

Guidance on String to Token Parsing Assignment (Just guidance, I don't want anyone doing it all for me.)

2 Upvotes

I was given an assignment for a class I am in and it is expected to be entirely in C code (despite most of us in the class having never been taught how to code with C). I have been attempting to find tutorials and websites, but not much is helping for the assignment itself. The assignment is due in two days.

If there is someone who could help explain how I should go about this, or what guides I could look at to help me code it, I would greatly appreciate it. I do not want anyone to do the work for me. I just would like some guidance.

---
This is a summarized version of what the assignment says:

Write a function, in C, that will parse a string into tokens (or words), similar to what the shell is required to do.

Write a function with the following prototype:

int makearg(char *s, char ***args);
or
int makearg(char s[], char **args[]);
(Correct prototype—don’t change)

This function should accept a (C-type) string and a pointer to a pointer to char (or, if you prefer, a pointer to an array of pointers to char), and should return the pointer defined to point to an array pointing to the separate tokens on the command line, as well as the number of tokens found as the function return value. If a problem occurs, the value returned should be -1.

No C library string functions may be used, e.g., strlen(), strcat(), strtok(), etc.

The main program should input a line, call the function, then print out the number of arguments found, and finally, display the arguments, one per line. The value of the pointer argument is undefined when passed to the makearg() function. makearg() must allocate any necessary dynamic memory necessary for use by the program. (The array used for the unparsed string need not be dynamically allocated.)
---

Again, I do not want someone to do the code for me, as I want to actually learn the content. I just want advice or guidance on what to do or where I can find resources. If anyone can do that, I would greatly appreciate it.


r/cprogramming • • 20h ago

I wrote a compiler entirely in NASM x86-64 assembly — no LLVM, no C runtime, no external deps

Thumbnail
0 Upvotes

r/cprogramming • • 1d ago

Sharing my modern C++ project template , looking for feedback, suggestions, and contributors!

Thumbnail
github.com
2 Upvotes

r/cprogramming • • 1d ago

I am learning C programming by making this project a unix shell(ForkOff). Looking for a quick code review!

15 Upvotes

Hello there,

I am learning C and system programming by building this shell named ForkOff.

Its currently handles command parsing, executing binaries with fork() + execv(), wait state, and basic buildins like cd echo pwd exit type

Repo: https://github.com/Anchit3034/ForkOff

I'd love a feedback on my memory management, pointer handling, and amy bad habits i should fix early on. Tips on adding piping next are also welcome!

Thanks!


r/cprogramming • • 1d ago

From logic gates to a self-hosting compiler: my undergraduate HPC course is almost fully available in English

Thumbnail
2 Upvotes

r/cprogramming • • 1d ago

How Can You Tell Whether a Project, an Image, or Code Is AI Slop?

6 Upvotes

Lately, I've been seeing AI slop everywhere, and I mean literally everywhere. I go on r/rust, and so many projects seem to be AI slop. I check r/lowlevel, and it's the same story. I'm honestly getting really tired of it.

How long is this going to keep going on?

What's even more surprising is that lately, I've been seeing major organizations outsourcing their projects to individuals who end up producing AI slop.


r/cprogramming • • 2d ago

We need games written in C

6 Upvotes

Me and my friend are making a project where we making open source game development tools, we are just starting so we dont have much! But we have a project generator!!!1!!

Your game needs to be transfered to the qwertyuiop-Games organization with it's own repo and team.

But the big part is that we made a game launcher that displays games made with our tools. Please help me with making games: You make every type of game, TUI, fantasy, adventure!


r/cprogramming • • 3d ago

Understanding Strings/String Manipulation in C

12 Upvotes

I'm a junior CS undergraduate finally tackling C programming and I just can't seem to grasp Strings as a whole. Concepts like string manipulation (using strlen, strncmp, snprintf, strdup, strtok), handling read-only strings vs dynamically allocated strings, allocating memory for strings in different scenarios, and creating writable strings. Despite my attempts in looking at readings, lecture slides, practice problems, I just can't seem to understand the various ways to deal with strings in C. I am a very formulaic thinker meaning steps and guidelines on how to approach problems is my way of solving them. Is there a general format for dealing with string questions in C. Like first you have to allocate memory, then depending on the type of string do this...

Are there any additional resources I'm missing out on as well? I really want to hone this concept down!


r/cprogramming • • 3d ago

My first 90% project I did my self bmp image renderer in c (I'm still working on it right now) What you think?

8 Upvotes
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <GLFW/glfw3.h>
#include <stdlib.h>


typedef struct{
    char signature[2];


    uint32_t file_size;


    uint16_t reserved_a;
    uint16_t reserved_b;


    uint32_t data_offset;
}bmpHeader;


typedef struct{
    uint32_t size;


    uint32_t p_width;
    uint32_t p_height;


    uint16_t plans;


    uint16_t bits_per_pixel;


    uint32_t compression;


    uint32_t image_size;


    uint32_t x_pixels_per_meter;
    uint32_t y_pixels_per_meter;


    uint32_t colours_used;


    uint32_t important_colours;


}infoHeader;


typedef struct{
    uint8_t blue;
    uint8_t green;
    uint8_t red;


}pixel_rgb;


int main(void){
    FILE *fptr;


    bmpHeader bmp;
    infoHeader info;


    fptr = fopen("image.bmp", "rb");
    
    fread(&bmp, 14, 1, fptr);
    fread(&info, 40, 1, fptr);


    pixel_rgb **pixel = malloc(info.p_height * sizeof(pixel_rgb*));
    for(int i = 0; i < info.p_height; i++){
        pixel[i] = malloc(info.p_width * sizeof(pixel_rgb));
    };


    int rowSize = (info.p_width * 3 + 3) & ~3; 
    int padding = rowSize - (info.p_width * 3);


    int width = info.p_width;
    int height = abs(info.p_height);



    fseek(fptr, bmp.data_offset, SEEK_SET);


    for(int i = 0; i < height; i++){
        for(int k = 0; k < width; k++){
            fread(&pixel[i][k], sizeof(pixel_rgb), 1, fptr);
        }
        fseek(fptr, padding, SEEK_CUR);
    }


    fclose(fptr);
    
    
     // Initialize GLFW
    if (!glfwInit()) {
        printf("Failed to initialize GLFW\n");
        return 1;
    }


     // Create a window
    GLFWwindow *window = glfwCreateWindow(
        width, height,
        "My First Window",
        NULL, NULL
    );


    if (window == NULL) {
        printf("Failed to create window\n");
        glfwTerminate();
        return 1;
    }


    // Make the window's OpenGL context current
    glfwMakeContextCurrent(window);
    glViewport(0, 0, width, height);


    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, width, 0, height, -1, 1);


    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();



     // Main window loop
    while (!glfwWindowShouldClose(window)) {
        // Clear screen BEFORE drawing
        glClear(GL_COLOR_BUFFER_BIT);
        glPointSize(1.0f);


        // Draw pixels
        glBegin(GL_POINTS);


        for (int i = 0; i < info.p_height; i++) {
            for (int k = 0; k < info.p_width; k++) {


                glColor3ub(
                    pixel[i][k].red,
                    pixel[i][k].green,
                    pixel[i][k].blue
                );


                glVertex2i(k, i);
            }
        }


        glEnd();


        glfwSwapBuffers(window);
        glfwPollEvents();
    }
     // Clean up
     glfwDestroyWindow(window);
     glfwTerminate();
    
    for (int i = 0; i < info.p_height; i++) {
        free(pixel[i]);
    }
    free(pixel);


    return 0;
}

r/cprogramming • • 3d ago

i want to make a game in C, any compiller reccomendations/library reccomendations?

19 Upvotes

so basicly as a bit of backstory im 16, i know scratch, luau, and 6502 assembly on the nes. but i have a dream game and i think i want to make it in C, as for somereason i have a obsession with low level programmeing, but i figured out assembly on modern stuff would be a little too painfull. but for my game i want to make it in the style of a 90s sega megadrive/genisis game but with a few features that would go past the megadrive limits (if this wasnt the base i would certainly make my game a actual megadrive rom), but i want to make this game have mp3 music and slightly higher res pixel screen so i think id rather not make this a rom for a retro console. i want this game to be cross platform, like so it can run on windows linux android via apk and maybe apple if im really pleased with the game.

-questions-

what graphics library should i use?

i want my games screen/window to me a pixelated res, and i want all the graphics to PIXEL SNAP (i hate it when i see games with collideing pixels), also if possible if it exists id like it if the graphics library didnt have any scaleing/rotateing sprite features as a think that would be unecessary for the fact i wont do any effects to the graphics as pixel art lookes ugly when rotated or scaled in my op.

what compiler should i use?

i dont mind too much but id prefer a workflow where i write code in notepad as for somereason i just like that, but then i also think i might give visual studio a go, idk. as my dad uses it i think..

note

please egnore my bad spelling and sentence structure. im bad at spelling, please excuse this i just want to type this message fast just because i just want some quick advice


r/cprogramming • • 3d ago

A PoC toolkit / framework for self modifying software.

1 Upvotes

Been working on this project during the summer, contains a detailed writeup but happy for anyone to tear the implementation a part, working on it while working fulltime kinda stopped me from implementing a lot of what i wanted.

Surprisingly enough it works well enough as a PoC!

https://gitlab.com/Epos95/paramorphism/

This is "self modifying software" in a different aspect than something like metamorphic software since the rewriting is on a source code level instead of assembly.

Currently its able to:

\- Dynamically create new functions, introducing new functionality

\- Fix errors in its own functions

\- Load existing functions dynamically


r/cprogramming • • 3d ago

Flint v0.5.20: My Git-native C/C++ build system now supports Windows!

Thumbnail
github.com
10 Upvotes

Hey everyone!

A few weeks ago, I started sharing **Flint**, an open-source build system and package manager for C/C++ that aims to make building projects and managing dependencies much simpler.

Today, I'm happy to share a milestone: **Flint v0.5.20 adds Windows support!** 🎉

## What is Flint?

The C/C++ tooling ecosystem often means juggling a build system, a separate package manager, and additional tooling just to get a project running.

I wanted to experiment with a simpler approach: something closer to the developer experience of Cargo or Go modules, but for C and C++.

Flint is written entirely in C and combines building projects with Git-based dependency management.

### What makes Flint different?

* **One manifest:** Configure your project through a single `composition.json` file instead of maintaining elaborate build scripts.

* **Git-native dependencies:** Add dependencies directly from Git repositories and pin them to versions and exact commits for reproducible builds.

* **Automatic source discovery:** Flint discovers project sources, headers, and libraries based on directory conventions, eliminating manual file lists.

* **Incremental builds:** Unchanged files don't need to be recompiled unnecessarily.

* **Editor integration:** Generate `compile_commands.json` for tools such as clangd and VS Code.

* **Minimal dependencies:** Flint is written in C and keeps its tooling footprint small.

### What's new in v0.5.20?

**Windows support is finally here.**

Until now, platform support was a major limitation for developers who wanted to try Flint on Windows. This release is an important step toward making the project accessible to more C/C++ developers.

I'm continuing to develop Flint and improve its usability, compatibility, and overall developer experience. There's still plenty of work ahead, and feedback from people trying it on real projects would be incredibly valuable.

## Try it out

**GitHub repository:**

https://github.com/mainak55512/flint

**CLI documentation:**

https://mainak55512.github.io/flint-cherts/

If you work with C or C++, I'd love to hear your thoughts:

* Does a lightweight, Git-native build system appeal to you?

* What would you want from a modern C/C++ package manager?

* If you're on Windows, could you try v0.5.20 and share your experience?

If you find Flint interesting, consider giving the repository a ⭐. It helps other developers discover the project and motivates me to keep building it.

Bug reports, constructive criticism, feature requests, and contributions are all welcome!

Thanks for checking it out!


r/cprogramming • • 2d ago

Ai nowadays

0 Upvotes

I want to read your thoughts.

I'm a software engineer with 8 years of experience, I have worked in several projects.

And ultimately I've become interested in C, I'm learning a lot of concepts about pointers and memory free, it's a different way of coding if you start with interpreted languages.

I have used ai for understand better some c concepts, and I've watched some c devs in the reddit community that hate the AI, why?

AI is just another tool, like a compiler, preprocessor etc. And I wonder why some devs don't like new tools? It's like if we avoid the compilers use and prefer keypunching instead.

The basics of Coding are important and I really believe there's bad use of ai and nice use of it too.

What do you think?


r/cprogramming • • 3d ago

Is anyone doing DSA with C programming ?? How to implement Hashset and Hashmaps in C programming ?

Thumbnail
0 Upvotes

r/cprogramming • • 3d ago

I've been building my own OS called VEX OS

0 Upvotes

Yo, so I've been working on my own operating system called VEX OS and thought I'd share it here.

The idea is to build an actual OS from the ground up, with its own bootloader, kernel, apps and eventually its own AI integrated into the system. I've been developing it in QEMU and I've managed to get it booting with stuff like a terminal and file explorer working. I'm also working on my own programming language called VexScript, which is part of the whole project. The AI side is called VEX AI. I'm developing that separately for now, but the plan is to integrate it directly into VEX OS rather than have it just be another app. Obviously, it's still a work in progress and there's a LOT left to do . I'm currently working towards getting VEX AI 1.5 integrated, then I want to make VEX OS bootable from a USB so people can try it out. I'm not gonna pretend it's anywhere near a finished product but I'm pretty happy with how far its come so far. What do you guys think, anyone else here working on their own OS or something similar?


r/cprogramming • • 3d ago

Help regarding AI usage

0 Upvotes

I am programming in C for a year and a half and I created projects like a shell which implement basic features , and currently finished building a TCP server with get and post request for sharing file across local network. The thing I am struggling with is the AI usage all these project I build I have understanding of the code. But sometimes I think that AI has found solution for me can I found this approach myself and mostly the answer was no. It really bothering me and I spend time completely without AI and frustration really hit hard and I think I couldn't start building some programs . I want advice from people on how to find balance between using AI and when not to use AI . I'll love to hear you guys perspective on this .


r/cprogramming • • 5d ago

Mucc: a self hosting C compiler in one static binary, with its own assembler, linker and musl (x86-64 and ARM64 Linux)

56 Upvotes

Mucc is a small C compiler for Linux that ships as a single 8.5 MB static file. The preprocessor, assembler, linker, archiver, headers and C library (musl, like zig cc does) are all built in, so you can drop it into an empty container, an old distro or a Raspberry Pi and build C with nothing else installed: no gcc, no binutils, no system headers. 

Programs it builds are static, so they run on any x86-64 Linux. There's a native ARM64 build too, and it can cross-compile between the two.

The whole project actually started as a fork of Rui Ueyama's chibicc. I felt more could be done on this design. So now Mucc adds its own assembler and linker, an ARM64 backend, register allocation, the bundled musl, DWARF debug info, C23 support and a reproducible bootstrap chain.

What’s actually working so far 

- C17 by default, C23 with `-std=c23`, plus the GNU extensions real code uses

- Self-hosting: each release is built by the one before it, and a Mucc-built Mucc produces byte-identical output

- Real projects build and pass their own test suites: SQLite, Lua, zlib, jq, Redis and Tcl with the bundled musl; CPython and Git with the system glibc

- Same ABI as gcc, so objects from either link together

- Compiles its own 33k lines in 0.46 s (gcc -O0: 1.22 s, gcc -O2: 5.35 s)

What’s currently not working, it does no optimization beyond register allocation and constant folding, so programs run about as fast as gcc -O0. No C++, Linux only. For performance-critical code, use gcc or clang.

If you've got C code it chokes on, or a use for it I haven't thought of, I'd like to hear it.

GitHub: https://github.com/Dom-Yan/Mucc

Website: https://dom-yan.github.io/Mucc/

Thanks to Rui Ueyama for chibicc, and to Fabrice Bellard, whose TinyCC showed how much a small compiler can do.


r/cprogramming • • 4d ago

I built a Windows folder size analyzer in C

Thumbnail
1 Upvotes

r/cprogramming • • 5d ago

How important is knowing syscalls in C?

16 Upvotes

Hello, idk if its just me I have been trying to get more and more into C but every video or concept or project I see people bring out 3 different syscalls that I have never heard of (that's a bit exaggerating but you know what I mean)

Am i supposed to know all of them? Memorise them?

Is there something I'm missing in terms of these bc I even realised they can be up to 500 different ones which is a lot to memorise, and even so how should I start learning them?


r/cprogramming • • 4d ago

My opinion about C development

Thumbnail
0 Upvotes

r/cprogramming • • 5d ago

A low-poly 3D renderer for MS-DOS

Thumbnail
github.com
15 Upvotes

I’ve been working on a small project called 3Dos — a low-poly 3D renderer targeting MS-DOS and VGA Mode 13h (320×200, 256 colors).

The renderer currently supports:
● Triangle rasterization with backface culling
● Ordered dithering using a 4×4 Bayer matrix
● Double buffering
● Simple low-poly models

Going back to DOS-era graphics has been relaxing after spending quite a bit of time with Vulkan. No boilerplate or abstractions, just putting a pixel at 0xA000.


r/cprogramming • • 5d ago

Rate my GitHub portfolio for junior C / systems programming jobs

8 Upvotes

I'm a self-taught C programmer building projects to improve my systems programming skills.

My main projects include:

A memory allocator implemented in C, with benchmarks against the standard allocator.

A small OOP-style system implemented in C.

An HTTP server in C that I'm developing into a backend framework.

GitHub: https://github.com/YanisBelkacemi

I'd appreciate honest feedback on:

  1. Code quality and architecture.

  2. Whether these projects demonstrate real understanding or just basic implementation skills.

  3. What's missing from my portfolio for junior C, systems programming, or firmware positions.

  4. What would make you reject this portfolio if you were reviewing candidates?

I'm looking for constructive criticism, not stars or compliments. Please be direct.


r/cprogramming • • 5d ago

is doing ~INT_MAX undefined behavior?

Thumbnail
5 Upvotes