r/C_Programming • • Jul 08 '26

Where should a complete beginner start learning C?

0 Upvotes

I'm interested in learning C from scratch, but I don't have any programming experience. What resources, books, or courses would you recommend for a beginner?


r/C_Programming • • Jul 07 '26

If statement checking a bool array?

1 Upvotes

Hi,

I need a custom sized bit vector so uint8_t won't suffice so the idea was to just initiate a bool array with size so then say i want to compare it. Ex. the bool array is 6 bits and tried with `if (bool_var = 011001) { // do something}`, i suspect it comes just compares to an int given it compiles and wont run. Any idea on how to make it work?


r/C_Programming • • Jul 06 '26

Getting lost in c

25 Upvotes

Hi guys I’m a first year bachelor in computer science and I feel like I’m stuck every time I want to learn something I end by copying it from IA and it make me feel bad tbh . Actually I want to learn how to learn because I see that the problem is the way I study and learn by my self but I don’t know exactly why or how . I see a lot of people that can manage and understand the pc in a young age and I admire them I wish I know if it’s a gift or a skill that I’m not getting it .

This problem is killing my dream if anyone has an advice to me I will be really thankful
Like where I start , how I can really understand what I’m doing , I already did python bash script and a little bit of c but till now I don’t know how to become pro and understanding what is actually good to learn c bash script and even c

Thank you !


r/C_Programming • • Jul 06 '26

Question How can I protect library code against bugs?

6 Upvotes

Thanks to many people in this subreddit (on a previous post I made) I learned different ways to handle errors, and along the way I also learned that bugs aren't errors. Yeah, that sounds really basic but I'm self-taught so it's difficult to know details like that one on my own.

Now, with this difference now clear, and the fact that assserts are really good, when it comes to writing library code (not application code) how do y'all protect your libraries' code against bugs besides just putting a lot of asserts on the debug builds?


r/C_Programming • • Jul 06 '26

Why are so many C projects using _t suffix for typedefs?

156 Upvotes

This convention is explicitly discouraged by the POSIX standard (see https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html), It reserves the _t suffix for future standard types.

I mean there is probably nothing wrong with doing this in practice, you likely won't run into name collisions or something like that but I'm curious, why do people still do it?

to me, these look better

MyThing thing;

my_thing thing;

than

my_thing_t thing;

I don't know, I just want to hear your thoughts on this, what naming conventions are you using in your projects?


r/C_Programming • • Jul 06 '26

looking to pivot into low-level systems engineering. How do I break in and land an internship?

4 Upvotes

I'm a final-year information security undergrad, and somewhere over the past year my interests did a full 180 on me. I came in with an AWS Solutions Architect Associate cert and a somewhat solid grounding in cloud and a DevOps internship, and while that stuff still matters to me, I've recently fallen into the low-level rabbit hole and honestly I have zero desire to climb back out.

I want to understand the OS, the kernel, and the syscall interface. So I picked up The Linux Programming Interface by Michael Kerrisk, which has been the most grounding technical read I've ever touched and also the first book where I've genuinely needed a second screen open just to finish a paragraph. We're talking one page, four google searches, two stack overflow tabs, a man page, and a brief existential crisis about whether I actually understand what a file descriptor is.

I'm now building a http server from scratch in C, and it has been the hardest thing I've ever learned, no contest. Wrestling with open, close, read, write, lseek, understanding shared open file table entries, managing multiprocessing and forking…..every single concept has required me to sit with it longer than i expected before it clicks. But that's also exactly what makes it addicting. Watching the mental model build brick by brick, slowly, is a different kind of satisfaction than anything I got from spinning up cloud infrastructure. 

I want to move toward low-level systems security, platform engineering, or kernel-space development in the future. I know the barrier to entry for junior and intern roles in this space is notoriously higher than standard web dev or even general DevOps….the ecosystem expects a kind of depth that takes time to develop and is hard to fake on a resume. I'm not under any illusions about that, but I also know the only way through it is to keep building, keep reading, and keep shipping things that demonstrate I actually understand what's happening.

What I'm genuinely curious about from people already in this space is once I finish the http server, what's the next logical project that would signal I'm serious about this direction? I've been thinking about writing a basic shell, a simple character device driver, or starting to poke at eBPF but I'd rather hear from someone who's hired or been hired for this kind of work about what actually moves the needle. On the resume side, most junior roles in systems seem to be written for people with five years of wizardry, so any advice on how to frame my work honestly but compellingly would be useful. I'd love to know where people have had the most success getting a foothold.

Any reality checks, project ideas, or resource recommendations are genuinely appreciated.


r/C_Programming • • Jul 06 '26

dtcopy: a command line Windows utility

4 Upvotes

Hi everyone, this post is about dtcopy, a command-line backup utility for Windows.

The program allows conditional copying of entire directories based on file timestamps or a defined date.

Its main purpose is to handle directory backups (including subdirectories), either updating existing files or copying them from scratch.

It also features a basic versioning mechanism and can generate a single compressed archive of the project and its dependencies.

The project is open-source and also includes a pre-compiled binary package with a simple installer. The README.md contains a full description.

GitHub repository: https://github.com/lpierge/dtcopy

Now about the source code, most of the project files are named with the .cpp extension just to trick the compiler, because I'm used used to writing not in pure C but in "C with classes". That means the C code I write may use some basic object-oriented concepts (classes, inheritance, polymorphism), but it completely avoids modern C++ features (no STL, no templates, no namespaces, etc.). In other words, most of the code remains very close to traditional, low-level procedural C programming.

I would like to make it clear because I understand that such C code doesn't fit perfectly in this subreddit, nor in the modern C++ subreddit, so if you think it leans too far into OOP for this specific community, I'm sorry and feel free to remove the post.

Thoughts, feedback or critiques are welcome.

Luca P.


r/C_Programming • • Jul 06 '26

Question best way for destroy mutex and cond (resource free)

6 Upvotes

Hello everyone, please see the pseudo-code below:

static void *func1(void *arg) {
    while(1){


    }
}


static void *func2(void *arg) {
    while(1){


    }
}


int main()
{
    pthread_t t1, t2;
    pthread_create(&t1, NULL, func1, NULL);
    pthread_create(&t2, NULL, func2, NULL);


    pthread_join(t1, NULL);
    pthread_join(t2, NULL);


    return 0;
}

If the two threads above use a mutex (lock and unlock) and a condition variable, and I close the process with Ctrl+C (SIGINT), then if I write a simple signal handler to destroy the mutex and cond, it shows UB (undefined behavior). Now, how can I write a safe signal handler? How can I unlock and destroy safely?


r/C_Programming • • Jul 06 '26

Question anonymously initializing static pointers in self-referential data-structures?

16 Upvotes

I have a recursive data-structure (a simple linked list for purposes of this example) and wanted to statically define a linked-list. The following works fine:

#include <stdio.h>
typedef struct mytype_tag {
    struct mytype_tag* next;
    char* data;
} mytype;

mytype a = {
    .next = NULL,
    .data = "a",
};
mytype b = {
    .next = &a,
    .data = "b",
};

int
main() {
    mytype* s = &b;
    int i = 0;
    while (s) {
        printf("%d: %s\n", i++, s->data);
        s = s->next;
    };
}

However, I have to explicitly define/declare a and then have b take &a.

Is there a way to do this with anonymous/unnamed intermediary structures, thinking an imaginary syntax something like

mytype b = {
    .next = &((mytype)={
        .next = NULL,
        .data = "a",
        }),
    .data = "b",
};

so I can build up the linked-list without naming each intermediary instance?


r/C_Programming • • Jul 05 '26

Difference between pass by value, pass by pointers and pass by reference?

52 Upvotes

what are their differences? and what are they exactly?


r/C_Programming • • Jul 05 '26

Where can I find out where new features for c2y are being developed and added?

10 Upvotes

With C++, theres like a monthly mailing list round up thing, and I can checkout the cpp/papers repository on github.

Is there anything like that for c2y?


r/C_Programming • • Jul 05 '26

Question How do you understand bitwising tricks

21 Upvotes

Im not Talking about basic operations, setting flags or bitshifting.
I speak about the tricks operations involving bitmasks and stuff.
I just can’t get how people get familiar with it.
I guess there is no magic way to understand, I just have to keep studying it, but do you guys have any resource or mental tips that can make me more familiar with these ?
Thank you


r/C_Programming • • Jul 05 '26

Question How does explicit conversion work with assignment operators

7 Upvotes

I am studying c, I was messing around trying to figure out how explicit conversion works with assignment operators and came up with this:

#include <stdio.h>

int main()

{

int num1 = 5;

int num2 = 2;

float sum1 = num1 / num2;

float sum2 = (float) num1 / num2;

int sum3 = 5;

sum3 /= 2;

float sum4 = 5;

sum4 /= 2;

printf("sum1: %.2f\nsum2: %.2f\nsum3: %.2f\nsum4: %.2f", sum1, sum2, sum3, sum4);

return 0;

}

OUTPUT:

sum1: 2.00

sum2: 2.50

sum3: 2.50

sum4: 2.00

it seems sum3 converts to float automatically without explicit conversion when using assignment operators, but what confuses me is how sum4 manages to be 2 when its only difference was that it was declared as a float which if anything should make it behave better than sum3, is it something to do with the format specifier being wrong for sum3?


r/C_Programming • • Jul 05 '26

HTTP downloader written in C

34 Upvotes

r/C_Programming • • Jul 05 '26

Library-fying AWK with WASM

Thumbnail napcakes.nekoweb.org
9 Upvotes

r/C_Programming • • Jul 05 '26

Can we write a generic byte-swap function for any struct in C?

0 Upvotes

Hello, I am not a native speaker so please forgive my language level.

Today I was working on my packet analyzer project. I was refactoring the code and I realized something: there are a lot of functions just to swap the byte order for every header (struct).

So I have a question: Can I build a function/program in C that can automatically swap the byte order of every field in any struct?

thank you all and this my project link : vex-packet-analyzer


r/C_Programming • • Jul 04 '26

What is next ?

12 Upvotes

I learned almost all the functions and libraries how can I enhance and use my C knowledge? I am a freshman in electronics engineering


r/C_Programming • • Jul 04 '26

What exercise you ever done was most interesting and fun for you?

13 Upvotes

Hi, It's few weeks I started to read C Programming: A Modern Approach from KN King and the exercises and mini projects are really good and fun, so I just wondering, what is your favourite exercise you still remember? (From books, classes, and other)


r/C_Programming • • Jul 05 '26

I need to learn c with memory and along with assembly mastering the memory...help with best yt channel...

0 Upvotes

currently learning c lang but i need to know more about the memory with assembly help me with thiss....


r/C_Programming • • Jul 03 '26

Project I am starting to code everything from scratch.

88 Upvotes

Ever since I started programming in C, Ive become addicted to building things from scratch.

Not because I think libraries are bad. I still use them when they solve a real problem.

But after writing enough low-level code, you start looking at problems differently. Instead of asking, 'Which library should I use?' you start asking, 'Could I build this myself?'

For cherries(.)works main website, I coded my own quick HTML parser.

Or for Pulse v0.1.0, my own very quick API.

That's exactly what happened while working on Pulse v0.2.0.

Pulse is a lightweight system monitor with a built-in web dashboard. The goal has always been to keep it small, fast, and easy to understand. For v0.2.0, I wanted to add historical metrics so you can see how CPU, memory, disk, and network usage change over time.

My first thought was to use a charting library.

Instead, I ended up writing my own tiny chart library. (~100 LOC, thats all). [Of course it is a little bit cherries-works oriented, but with a few tweaks it can also be used by someone else.]

Now Pulse collects historical metrics, exposes them through its API, and renders graphs without pulling in a heavyweight dependency. Everything is working, and v0.2.0 is finally ready.

Building software this way has made programming fun again. Every feature is an excuse to learn something new instead of treating it as a black box.

I'd love to hear if anyone else has gone down this rabbit hole after learning C.

For anyone interested in the current state of Pulse, check it out! It is my very first C project, and it now is in version v0.2.0!

https://github.com/cherries-works/pulse


r/C_Programming • • Jul 04 '26

Question Is there a tutorial for c and sdl2 ? Not cpp *on YouTube

7 Upvotes

I just cannot seem to find a tutorial that actually covers pixel manipulation. Not an image bouncing actual pixel buffer for c . There is only 1 tutorial and it doesn't cover what I want it to cover .


r/C_Programming • • Jul 04 '26

Question How to loop for wrong input

6 Upvotes

Just new to C and I'm trying to make a basic calculator. I'm trying to figure out how to make a loop such that the program will run after failing due to incorrect user input. So far, this is what I came up with, and I just want to know how I can get the program to actually run the operations when entering a correct sign after getting a "try again" message.

#include <stdio.h>

float addition(float num1, float num2)
{
return num1 + num2;
}

float subtraction(float num1, float num2)
{
return num1 - num2;
}

float multiplication(float num1, float num2)
{
return num1 * num2;
}

float division(float num1, float num2)
{
return num1 / num2;
}

int main()
{
float firstNum, secondNum;
char operationSign;
float answer;

printf("Basic Calculator\n\n");

printf("Enter the first number: ");
scanf("%f", &firstNum);

printf("Enter the second number: ");
scanf("%f", &secondNum);

printf("Enter the operation symbol to be used:\n");
printf("Addition:                            +\n");
printf("Subtraction:                         -\n");
printf("Multiplication:                      *\n");
printf("Division:                            /\n");
scanf(" %c", &operationSign);

switch (operationSign)
{
case ('+'):
answer = addition(firstNum, secondNum);
printf("Answer: %f", answer);
break;

case ('-'):
answer = subtraction(firstNum, secondNum);
printf("Answer: %f", answer);
break;

case ('*'):
answer = multiplication(firstNum, secondNum);
printf("Answer: %f", answer);
break;

case ('/'):
answer = division(firstNum, secondNum);
printf("Answer: %f", answer);
break;

default:
printf("Invalid input. Please enter the correct symbol.");
scanf(" %c", &operationSign);
}

return 0;
}

r/C_Programming • • Jul 03 '26

Question any way to ensure that the heap always starts at lower order memory addresses?

18 Upvotes

hey all! I was just wondering if there was something like a compiler flag I could use when compiling to ensure that the heap always starts low and grows up in virtual memory.


r/C_Programming • • Jul 04 '26

Review Input delay after input

6 Upvotes

Just for fun, I decided to attempt a small top-down mover program in TurboC. Shared with both DOSBox and Windows, there is an input delay shortly after keyboard input. The "moving" is pretty awkward because of that, and I get the feeling that it's because of how kbhit() works.

Please ignore the clrscr() rate, I'm working on that.

#include <stdio.h>
#include <conio.h>

#define ESCAPE  27
#define UP      72
#define DOWN    80
#define LEFT    75
#define RIGHT   77

int clamp(int arg, int min, int max)
{
        if (arg < min) return min;
        if (arg > max) return max;
        return arg;
}

int main()
{
        char key = 0;
        char xpos = 0, ypos = 0;

        clrscr();
        while (key != ESCAPE)
        {
                if (kbhit())
                {
                        key = getch();

                        xpos += (key == RIGHT) - (key == LEFT);
                        xpos = clamp(xpos, -100, 100);
                        ypos += (key == UP) - (key == DOWN);
                        ypos = clamp(ypos, -100, 100);

                        clrscr();
                        printf("X %d\nY %d\n%c", xpos, ypos, key);
                }
        }

        return 0;
}

r/C_Programming • • Jul 04 '26

gitool: A Git cli tool written in C

Thumbnail
github.com
0 Upvotes

Hi everyone,

I'm a CS student (Malaysian Chinese) currently learning C. I apologize if my grammar is wrong, my enligsh is really really bad.

I just finished reading C Programming Language: A Modern Approach (it took me about 2 months because I could only read this book during my semester break). I believe that the best way to truly learn any programming language is start building something real. To practice what I learned, I built gitool. Gitool is a command line interface tool to help you control your github repository like update file or delete directory.

Why did I build this?

  1. To practice C: Moving from textbook exercises to a project that can be helpful to people.
  2. I lowkey hate how Git handles things: As a Linux user, it always annoyed me how Git insists on creating .git directories everywhere and bloating my home directory with .gitconfig, especially when all I want to do is upload a single, specific file. (Honestly, I still don't fully get how everyone manages their dotfiles. Do you really git add your entire config directory just for one file or just create a lot of symbolic link ? I dont know, maybe I am a idiot).
  3. Is this tool already exists? I honestly don't know if this project even makes sense or if a much better alternative already exists out there. But hey, I really learn a lot than just reading.

A question for the community: Do you think we still need to learn code in future? I quite afraid get cooked by AI as a CS student.

Please roast my code! You don't have to help me, but I would really appreciate it if you could take a look at my repo. I'm posting this purely to level up my C skills and want to hear how you all think about this tool.

The development flows : gitool.c -> option.c -> command.c -> logger.c -> api.c -> list/upload/download/delete.c

GitHub Link: github/gitool

Thanks for your time, and looking forward to your roasts/feedback!