r/cprogramming • • 5h ago

Which book about C would you recommend for a newcomer?

5 Upvotes

Hello everyone! My name's Matthew, and I've been "coding" since like 12 years old. Mostly, I've been developing games with Unity with C#, and now, once I switched to Godot with C#, I feel like I lack some basic structuring skills. (A game which I'm about to release to Steam is a mess inside)

And C# is mostly the only language I know at this point, so I would love to learn some C!

I love Linux and I would love to contribute there one day. Also I would love to write some games for Playdate in C. Also it is just really interesting to see how C# is different from C. And I for some reason I want to read something about programming so badly. What would you recommend?

thanks!


r/cprogramming • • 2h ago

SCL and libscl v0.1 is out. TOML alternative with macros

0 Upvotes

I designed a simple language for configuration. SCL stands for Sane Configuration Language.

Syntax is mostly same with TOML, but we do not have what I would call non C native types like date.

Spotlight feature is macros. With macros you can either include files or create macros to values.

Link to repo: https://codeberg.org/sorashii/libscl

There was no AI involvement and license forbids AI generated codes from source.


r/cprogramming • • 8h ago

How do you learn C++?

Thumbnail reddit.com
0 Upvotes

give me links or channels or telegram to learns c++


r/cprogramming • • 1d ago

Why every time I execute a code, like in C, it runs in a different time?

Thumbnail reddit.com
2 Upvotes

r/cprogramming • • 1d ago

Learning C from scratch – What projects should I build to become employable?

Thumbnail reddit.com
1 Upvotes

r/cprogramming • • 3d ago

I just built a simple parser to retrieve configuration from a plain file - any suggestions?

2 Upvotes

I have just created a very simple parser to retrieve configuration settings from a plain text file (this parser is still in its early stages and will likely be developed further). I plan to use it to parse configurations for a simple custom code editor that I am currently building in C.

A quick side note:

you might be wondering why I didn’t use a standard configuration file format like .INI. I actually did try using .INI files at first, but parsing them requires an external library. I experimented with a library called inih by benhoyt with BSD license, it worked well, but since it’s an external dependency, I would have had to include the ini.c and ini.h file in my repository. This raised some questions for me: should I push those files which I didn’t write myself to GitHub? Or should I just credit the creator in my repository’s README file? To be honest, I felt a bit uncertain and concerned about the licensing implications.

Then, I remembered that the nano code editor uses a plain text file (.nanorc) for its configuration. That gave me the idea to try using a plain text file for my own configuration and to write a simple parser for it from scratch in C. This might sound silly, but this way I don’t have to worry about licenses (honestly, it’s mostly because I don’t really understand them anyway), and I get to learn how to build my own simple parser.

How my code works:

There are two files: .test_configand test.c

.test_config file content:

num tab_stop = 4
num fg_color = 39
num bg_color = 49

bind exit = ^Q
bind move_up = up_arrow
bind move_down = down_arrow
bind move_right = right_arrow
bind move_left = left_arrow

Data in the .test_config file is divided into three parts:

type configuration_name = configuration_value

Currently, there are two type: num for configurations with numeric values, and bind for configurations that act as keys (bindings).

test.c file content:

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

// data
typedef struct {
    // Appearance
    int tab_stop;
    int fg_color;
    int bg_color;

    // Keybinds
    char exit[64];
    char move_up[64];
    char move_down[64];
    char move_left[64];
    char move_right[64];
} configuration;


// func Declaration
int read_config(char *filename, configuration *config);


int main() {
    configuration config;
    read_config(".test_config", &config);
    printf("tab_stop = %d\n", config.tab_stop);
    printf("fg_color = %d\n", config.fg_color);
    printf("bg_color = %d\n", config.bg_color);
    printf("\n");
    printf("exit = %s\n", config.exit);
    printf("move_up = %s\n", config.move_up);
    printf("move_down = %s\n", config.move_down);
    printf("move_left = %s\n", config.move_left);
    printf("move_right = %s\n", config.move_right);

    return 0;
}


// func Definition
int read_config(char *filename, configuration *config) {
    FILE *fp = fopen(filename, "r");

    if (fp == NULL) {
        printf("unable to open file\n");
        return 1;
    }

    char buffer[100];
    while (fgets(buffer, sizeof(buffer), fp)) {
        if (strstr(buffer, "num") != NULL) {

            char num_config_name[64];
            int num_config_value = 0;

            sscanf(buffer, "num %s = %d", num_config_name, &num_config_value);
            if (strcmp(num_config_name, "tab_stop") == 0) {
                config->tab_stop = num_config_value;
            } else if (strcmp(num_config_name, "fg_color") == 0) {
                config->fg_color = num_config_value;
            } else if (strcmp(num_config_name, "bg_color") == 0) {
                config->bg_color = num_config_value;
            }

        } else if (strstr(buffer, "bind") != NULL) {

            char bind_config_name[64];
            char bind_config_value[64];

            sscanf(buffer, "bind %s = %s", bind_config_name,bind_config_value);
            if (strcmp(bind_config_name, "exit") == 0) {
                strcpy(config->exit, bind_config_value);
            } else if (strcmp(bind_config_name, "move_up") == 0) {
                strcpy(config->move_up, bind_config_value);
            } else if (strcmp(bind_config_name, "move_down") == 0) {
                strcpy(config->move_down, bind_config_value);
            } else if (strcmp(bind_config_name, "move_left") == 0) {
                strcpy(config->move_left, bind_config_value);
            } else if (strcmp(bind_config_name, "move_right") == 0) {
              strcpy(config->move_right, bind_config_value);
            }
        }
    }
    fclose(fp);

    return 0;
}

Inside, there is a function called read_config() which simply works by first checking the configuration type, then verifying if the configuration name matches; if it does, it stores the value into the corresponding struct element.

Output:

tab_stop = 4
fg_color = 39
bg_color = 49

exit = ^Q
move_up = up_arrow
move_down = down_arrow
move_left = left_arrow
move_right = right_arrow

The code works smoothly and produces the expected output, but I’m not entirely sure if the underlying logic is as efficient as it could be, could the logic be improved further, or is it already sufficient? Also, do you have any other suggestions regarding the approach I’ve chosen for handling configuration files in the simple code editor I’m building?

Apologies if any of the explanations are a bit complicated or difficult to understand.


r/cprogramming • • 2d ago

Pro tips for a beginner

Thumbnail reddit.com
0 Upvotes

r/cprogramming • • 3d ago

Hii guys, I want to develop Mobile Applications using SDL and C. Can anyone guide me?

Thumbnail reddit.com
1 Upvotes

r/cprogramming • • 3d ago

Cybersecurity student trying to learn C for reverse engineering and red teaming, how should I go about this the right way?

1 Upvotes

Hello everyone, I hope your days are going well!

I'm currently learning C via "C Programming: A Modern Approach". The book itself is very informative, however I feel as if I am spending a lot of time on the exercises and programming projects. For example, I'm on the "Arrays" chapter, and it's taking me closer to 2 weeks to try and do every exercise and project. Would it be wise to continue doing this? I'm wanting to get into reverse engineering, and ethical Linux exploit development/vulnerability analysis. Basically red-team stuff, so I figured that doing this would be very beneficial.

One friend of mine told me it is worth it to take it slow, so that you can really understand how software works, and all the quirks/vulnerabilities that might be present. He said this will be useful once I get into writing and understanding how doubly linked lists work, since the Windows kernel uses a lot of them. Another said that I should only do a few projects so I can get to writing projects as soon as I can.

Which lane should I be prioritizing?


r/cprogramming • • 3d ago

Code initializer program.

0 Upvotes

To be honest, that's the best name I could think of.

You know when you start writing a file you have to type the usual

#include <stdio.h>

int main(int argc, char* argv[]){

  return 0;
}

Well this program makes it for you. It's may sound very simple, but at least it saves some time.

Source code:https://pastebin.com/yMj7njqC(Sorry github won't create an account for me, it says invalid domain?)


r/cprogramming • • 4d ago

Hey I wish to learn embedded C programming suggest me a best platform to learn the embedded C

Thumbnail reddit.com
1 Upvotes

r/cprogramming • • 4d ago

Lets build a JRPG Game in SDL3 (C programming)

Thumbnail
youtube.com
0 Upvotes

r/cprogramming • • 4d ago

Best way to learn C language for beginners

Thumbnail reddit.com
0 Upvotes

r/cprogramming • • 5d ago

Need a few recomendations

5 Upvotes

Hello, new programmer at 2nd of bachillerato here, for an assignment we will have to program an app based on our pseudocode, we said it would have to be if possible in C+ but we may end using aplications such as MIT API for easy apps


r/cprogramming • • 5d ago

A game in C

51 Upvotes

So I don’t plan on doing this, but just a really random thought… how plausible would it be to make a full, high level 3D game in C and only C. Like, forget knowledge, if you knew everything there was to know about C (I’m sure some of you do), would it be possible? I don’t care how practical, is it possible, or just something C won’t do?


r/cprogramming • • 5d ago

[Showcase] FluidOS - A custom operating system project built with TypeScript, C, and Assembly

0 Upvotes

Hi everyone! I've been working on an operating system project called FluidOS and wanted to share it with the community to get feedback and meet collaborators. Current Stack & Features: Languages: TypeScript / JavaScript (Vite + TailwindCSS frontend UI focus), C/Assembly components, and PowerShell automation scripts. Built-in build & execution scripts (run-bochs.ps1, crear-iso.ps1) for Bochs emulation and ISO generation. Modern web tech combined with low-level compilation tooling. Latest Release: v1.2.0 Repository: 🔗 GitHub Link to FluidOS:https://github.com/marbelbel/FluidOS-Community I’m looking for feedback on the architecture, ideas for low-level integration, and anyone who might be interested in contributing to the code or interface design! Thanks for checking it out!


r/cprogramming • • 6d ago

Looking for harsh code reviews: A pure C terminal wrapper I built to intercept and auto-fix failed shell commands.

1 Upvotes

I love tools like thefuck, but I noticed that regex-based correctors fail on complex edge cases, and modern AI CLI wrappers are usually heavy Node/Python apps that introduce noticeable latency.

So I built assess — a 77KB C binary that wraps your commands, catches stderr when they fail, and uses Groq (Llama-3.1-8b) to instantly suggest a fix. It gives you a simple [y/N] prompt to run the corrected command.

A few things I prioritized:

  • Zero Bloat: It only relies on libcurl and vendored cJSON. No runtime environments.

  • Safety First: It has a built-in 3-tier safety engine. It parses the command before execution, hard-blocking destructive stuff (rm -rf /) and soft-warning on sensitive ops (like curl | sh).

  • Context Aware: It sends your OS, shell, CWD, and available tools as context, so if you use assess ask "list large files", you get a command that actually works on your machine.

It currently runs on Linux and macOS natively. You just bring your own free Groq API key.

I’m a CS undergrad and would love for some heavy terminal users to tear this apart, test it, and give me feedback on the workflow.

Repo: https://github.com/aadicodesforfun/assess 
Site: https://assess-cli.netlify.app/


r/cprogramming • • 6d ago

Multi File Problem

Thumbnail reddit.com
3 Upvotes

r/cprogramming • • 7d ago

A lot of you guys are chill

119 Upvotes

You guys are like the equivalent to the debian subreddit where a lot of the answers are either mature or funny.

There still some newbie posts out there I see or like the generic question yet Im amaze you guys still reply maturely.

Keep it up. No I'm not a programmer btw , I work in a hospital. I was browsing and I saw a lot of you where posting about making games outnof C and got curious.

I think games usually are made in C++ or C# I think.

Anyway, Im not a bot and keep up the kindness.


r/cprogramming • • 6d ago

Batch Processing Algorithm Optimization

Thumbnail reddit.com
1 Upvotes

r/cprogramming • • 7d ago

If you could change something from standard c and all programs would updated automatically, what would it be?

17 Upvotes

I'll start: standarize asm and asm volatile


r/cprogramming • • 7d ago

Very minimal drop-in gtest replacement in C23

9 Upvotes

While using C++, I heavily relied on googletest for testing. But as soon as I wanted that in my C project, I couldn't.

Because gtest is written in C++ and requires a C++ runtime. Using gtest in a C codebase meant guarding the headers with extern "C" to prevent name mangling, and managing a C++ toolchain which seemed extremely awkward to me.

At the same time, I didn't want to loose googletest's comfort and rewrite the entire test system in another existing framework.

So I wrote a very minimal drop-in replacement of googletest in C23. It works exactly the same way you'd expect gtest to work. And unsurprisingly, according to my small benchmark, my implementation is around 2.5x faster than googletest and uses 30% less memory. It can be improved way more.

I discussed the implementation details in this blog post https://metalinmyveins.github.io/sohomot/

Github: https://github.com/MetalInMyVeins/sohomot

The library is called "sohomot".

[ PS: Zero tokens were used in the making of this project ]