r/c_language • • 18d ago

libcli - a singe-header library for typed argument parsing in C

6 Upvotes

Using macros, define an argument schema. The library then generates a struct that for the schema, validates the arguments provided by the user, parses them into the struct, and offers functions for displaying usage andh help messages in the console.

It is similar to `clap` in Rust. Check it out!

https://github.com/iColgateZz/libcli


r/c_language • • 18d ago

Focp class practical ds bhopal

1 Upvotes

#include <stdio.h>

int fun1(void);

int fun2(void);

int fun3(void);

int x; /* Global variable */

int main(void)

{

x = 10;

printf("x = %d\n", x);

printf("x = %d\n", fun1());

printf("x = %d\n", fun2());

printf("x = %d\n", fun3());

return 0;

}

int fun1(void)

{

x = x + 10;

return x;

}

int fun2(void)

{

int x; /* Local variable */

x = 1;

return x;

}

int fun3(void)

{

x = x + 10; /* Global x */

return x;

}

#include <stdio.h>

void function1(void);

void function2(void);

int main(void)

{

int m = 1000;

function2();

printf("%d\n", m); /* Third output */

return 0;

}

void function1(void)

{

int m = 10;

printf("%d\n", m); /* First output */

}

void function2(void)

{

int m = 100;

function1();

printf("%d\n", m); /* Second output */

}

/* Write a multifunction to illustrate how automatic variables work */

void function1(void);

void function2(void);

int main()

{

int m = 1000;

function2();

printf("%d\n", m); /* Third output */

}

void function1(void)

{

int m = 10;

printf("%d\n", m); /* First output */

}

void function2(void)

{

int m = 100;

function1();

printf("%d\n", m); /* Second output */

}

#include <stdio.h>

int sqr(int x);

int main(void)

{

int t = 10;

printf("%d %d", sqr(t), t);

return 0;

}

int sqr(int x)

{

x = x * x;

return(x);

}

#include <stdio.h>

void counterFunction()

{

static int count = 0;

count++;

printf("Function called %d time(s)\n", count);

}

int main()

{

int i;

printf("Demonstrating static storage class in C:\n");

for(i = 0; i < 5; i++)

{

counterFunction();

}

return 0;

}

/* Program in recursion in C programming language - to find a number in an array */

#include <stdio.h>

int arr[5] = {1, 2, 3, 4, 5};

int search(int arr[], int N, int i, int x);

int main()

{

int j;

j = search(arr, 5, 0, 4);

if(j == 1)

{

printf("Found !!!");

}

else if(j == 0)

{

printf("Not Found");

}

return 0;

}

int search(int arr[], int N, int i, int x)

{

if(i == N)

{

return 0;

}

else if(arr[i] == x)

{

return 1;

}

else

{

return search(arr, N, ++i, x);

}

}

/* Call by reference - A program to return more than one value */

#include <stdio.h>

void aeraperi(int r, float *a, float *p);

int main()

{

int radius;

float area, perimeter;

printf("\nEnter radius of a circle");

scanf("%d", &radius);

aeraperi(radius, &area, &perimeter);

printf("Area=%f", area);

printf("\nPerimeter=%f", perimeter);

return 0;

}

void aeraperi(int r, float *a, float *p)

{

*a = 3.14 * r * r;

*p = 2 * 3.14 * r;

}


r/c_language • • 26d ago

The official C language website probably shouldn't be ranked so low

Post image
1 Upvotes

r/c_language • • 28d ago

Complete beginner struggling with C – Looking for a very slow, jargon-free guide/resource for college homework

Thumbnail reddit.com
0 Upvotes

r/c_language • • Oct 14 '26

C language

0 Upvotes

I am btech first year student and I want to learn C language. How can I learn it in easy way , can anyone suggest who have knowledge about it ????


r/c_language • • Oct 05 '26

Learn C

13 Upvotes

I really want to learn c programming from basic to advance is there any free course on internet or telegram

Don't say you tube

I saw them they are teaching basic stuff


r/c_language • • Sep 16 '26

CZet – A more powerful C without C++, 100% ISO C compatible

3 Upvotes

I'm the author.

All your C code already compiles as CZet. It just adds what C can't do without touching the compiler:

`defer`, monomorphized generics `T f<T>()`, `constexpr` functions, `_Reflect(T)` reflection, `_Operator` overloading, and `_Macro` macros Rust-style.

Single static binary with musl+glibc embedded, no system headers needed. Stdlib included: `#include <utils/...>` with no flags.

Repo + docs + examples: https://github.com/patrick-nonedev/CZet

GPL-3.0 + Runtime Exception (your binaries are NOT GPL).

What would you steal for plain C?


r/c_language • • Sep 12 '26

What C function would you delete and rewrite first, and why?

Thumbnail reddit.com
0 Upvotes

r/c_language • • Jul 11 '26

About the concept of Memory in C language as compare to other langs.

Thumbnail reddit.com
1 Upvotes

r/c_language • • Jun 18 '26

How to learn programming using C?

19 Upvotes

I'm new to programming and I chose C as my first language (kind of, actually java was my first, but I didn't like OOP and decided to go with C). I need to learn some programming concepts while I learn the syntax of C. Do you have any books to recommend to me?


r/c_language • • Jun 04 '26

Matrix rain in C and Raylib

Thumbnail
reddit.com
4 Upvotes

r/c_language • • Jun 02 '26

[recommendation] Learning C for Low-Level Concepts

3 Upvotes

I have prior experience in Python, I made Useful programs that are for me, such as, file handling..

I have learned some basics of C. Now, What shall I practice to create something? Should I program something similar that I made in Python?

Since, I am Learning C for Understanding Low Level. It will be beneficial for me to adapt into my career in Cyber Security/ Hacking, Malware Creation, Understanding Linux (UNIX is based on C).

And What Articles shall I read related to my career?


r/c_language • • May 26 '26

Working on a lightweight C testing framework, what features would you want?

Post image
1 Upvotes

r/c_language • • Apr 30 '26

I spent 6 months writing a face embedding engine in C + AVX2 that beats ONNX Runtime by 23%

3 Upvotes

Wrote a face embedding library from scratch using C99 and some manual SIMD optimization. Managed to squeeze out 23% more perf compared to ONNX Runtime running on identical hardware. No bloat, just raw speed.

The numbers

The numbers

FaceXONNX Runtime
Median latency3.0 ms3.9 ms
Min latency2.87 ms3.18 ms
Library size148 KB28 MB
Total w/ weights7 MB157 MB
DependencieszeroPython + onnxruntime
LFW accuracy99.73%99.73%

API — 4 functions, one headerThe numbers

// Include the single header
#include "facex.h"

// Initialize (~100ms, once)
FaceX* fx = facex_init("weights.bin", NULL);

// Compute embedding (3ms per call)
float embedding[512];
facex_embed(fx, rgb_112x112, embedding);

// Compare two faces
float sim = facex_similarity(emb_a, emb_b);
// sim > 0.3 → same person

facex_free(fx);// Include the single header
#include "facex.h"

// Initialize (~100ms, once)
FaceX* fx = facex_init("weights.bin", NULL);

// Compute embedding (3ms per call)
float embedding[512];
facex_embed(fx, rgb_112x112, embedding);

// Compare two faces
float sim = facex_similarity(emb_a, emb_b);
// sim > 0.3 → same person

facex_free(fx);

Optimization journey: 24ms → 3ms

Started with a naive C port of the ONNX graph—initial results were around 24ms. I started profiling every op to see where the cycles were going and stumbled onto a really weird bottleneck:

The real killers were:

  • LayerNorm × 17 blocks — scalar mean/variance loop → custom AVX2 fused single-pass

  • GELU × 17 — naive tanh() via math.h → polynomial erf with custom _mm256_exp_ps

  • Depthwise conv — HWC↔CHW transposes on every block → native HWC layout, zero transposes

  • MatMul → INT8 GEMM with vpmaddubsw (AVX2) and vpdpbusd (AVX-512 VNNI)

  • Memory → pre-packed weights, static workspace, no malloc per call

Tech: C99, ~4000 LOC, AVX2/FMA/AVX-512 VNNI. Apache 2.0.

GitHub: https://github.com/facex-engine/facex Repo's only 5 days old because I moved it from private to public. The actual code's been in the works for about 6 months check the README if you're curious.


r/c_language • • Apr 19 '26

Making a port of Inquirer.js to C

Thumbnail
github.com
3 Upvotes

r/c_language • • Mar 22 '26

My first C Malware sample: Implementing basic Anti-Debugging (TracerPid check)

6 Upvotes

Hi everyone⁦(⁠˘⁠・⁠_⁠・⁠˘⁠)⁩ I'm a first-year Computer Science student and I've been diving into low-level programming and malware development I wanted to share my very first "malware" experiment written in C What it does: It performs a basic anti-debugging check by parsing /proc/self/status to look for a non-zero TracerPid. If a debugger is detected, it exits silently. Otherwise it creates a "secret" file and attempts to send a notification via a web request (Telegram/Email simulation) I know the code is still raw and has plenty of room for improvement (especially in error handling and string obfuscation) but I'd love to get some feedback from the community on the logic or any suggestions for more advanced anti-analysis techniques to study next! ⁦(⁠ꏿ⁠﹏⁠ꏿ)⁩ Link to the Repository yousra-cyber/my-c-projects https://github.com/yousra-cyber/my-c-projects Thanks in advance for any tips!!!⁦(⁠◉⁠‿⁠◉⁠)


r/c_language • • Feb 10 '26

The C sandbox your AI agent deserves.

Thumbnail reddit.com
0 Upvotes

r/c_language • • Jan 24 '26

some C habits I employ for the modern day

Thumbnail
unix.dog
30 Upvotes

r/c_language • • Jan 08 '26

Mastering C for Cybersecurity on Mobile: My Roadmap 🌸

Post image
157 Upvotes

Hi everyone! I'm an 18yo student I’m learning C programming to build a strong foundation for Cybersecurity. Since I’m currently using my smartphone and a notebook, I’ve designed this roadmap (check images) to stay organized. I just finished "Loops" and I'm diving into "Pointers". I know AI can give roadmaps, but I value human experience more—you guys know the "real" traps. My questions: Is this roadmap solid for someone aiming for Cybersecurity? What's the most important "Low-level" concept I should focus on? Any tips for practicing logic on a small screen? Thanks for your wisdom! 🚀


r/c_language • • Jan 03 '26

Programming objects in C in style of Go

0 Upvotes

Hi there,

What do you folks think about this approach of programming objects in C? It supports non-virtual methods and private members.

goc.h

#ifndef GOC_H
#define GOC_H

#define fn(obj, fn, ...) (obj).fn(&(obj), ##__VA_ARGS__)

#endif

woman.h

#ifndef WOMAN_H
#define WOMAN_H

#include "goc.h"

struct woman;

typedef struct w {
    struct woman *w;
    void (* hug)(struct w *self);
    void (* kiss)(struct w *self);
} woman;

woman new_woman(char *);
void free_woman(woman *);

#endif

woman.c

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

#include "woman.h"

struct woman {
    char *name;
    bool hugged;
    bool kissed;
};

void hug(woman *self) {
    if (self->w == NULL) {
        printf("No woman allocated!\n");
        return;
    }

    printf("You're hugging %s\n", self->w->name);

    if (self->w->hugged) {
        printf("%s say: It hurts, get off me!\n", self->w->name);
        return;
    }
    if (self->w->kissed) {
        printf("%s say: Get off me, creep!\n", self->w->name);
        return;
    }

    self->w->hugged = true;
    printf("%s say: you're sweet!\n", self->w->name);
}

void kiss(woman *self) {
    if (self->w == NULL) {
        printf("No woman allocated!\n");
        return;
    }

    printf("You're kissing %s\n", self->w->name);

    if (!self->w->hugged) {
        if (self->w->kissed) {
            printf("%s is calling the police!\n", self->w->name);
            return;
        }
        self->w->kissed = true;
        printf("%s say: How dare you?\n", self->w->name);
        return;
    }
    if (self->w->kissed) {
        printf("%s say: Level up, boy!\n", self->w->name);
        return;
    }

    self->w->kissed = true;
    printf("%s say: Mwah!\n", self->w->name);
}

woman new_woman(char *name) {
    struct woman *w = calloc(1, sizeof(struct woman));
    w->name = name;
    woman women = {
        .w = w,
        .hug = hug,
        .kiss = kiss
    };
    return women;
}

void free_woman(woman *w) {
    free(w->w);
    w->w = NULL;
}

main.c

#include <stdio.h>

#include "woman.h"

int main(void)
{
    woman woman;

    printf("\033[1mThe right workflow:\033[0m\n");

    woman = new_woman("Alice");
    fn(woman, hug);
    fn(woman, kiss);
    fn(woman, kiss);
    free_woman(&woman);

    putchar('\n');

    printf("\033[1mThe wrong workflow:\033[0m\n");

    woman = new_woman("Miranda");
    fn(woman, kiss);
    fn(woman, hug);
    fn(woman, kiss);
    free_woman(&woman);

    putchar('\n');

    printf("\033[1mThe dreaming workflow:\033[0m\n");

    fn(woman, hug);
    fn(woman, kiss);
    fn(woman, kiss);

    return 0;
}

This program prints:

The right workflow:
You're hugging Alice
Alice say: you're sweet!
You're kissing Alice
Alice say: Mwah!
You're kissing Alice
Alice say: Level up, boy!

The wrong workflow:
You're kissing Miranda
Miranda say: How dare you?
You're hugging Miranda
Miranda say: Get off me, creep!
You're kissing Miranda
Miranda is calling the police!

The dreaming workflow:
No woman allocated!
No woman allocated!
No woman allocated!

r/c_language • • Nov 18 '25

jserv/mazu-editor: a minimalist text editor in C with syntax highlight, copy/paste, and search

Thumbnail
github.com
10 Upvotes

r/c_language • • Nov 15 '25

A new version of the gf gdb frontend (linux)

13 Upvotes

The gf debugger frontend as written by nakst is a pretty cool piece of software. I started using it daily a couple of years ago.

Mostly it worked great, but there were some things that bugged me, mostly missing functionality, so I started hacking at it on my free time. It was really nice to be able to fix something, and enjoy using it immediately. See this page for a list of improvements.

My repo can be found here. You can either build the gf executable yourself using cmake, or use the latest release includes a pre-built executable which should run on any modern linux. The gf executable is standalone and can just be copied into any bin directory on your path. Let me know what you think!


r/c_language • • Nov 06 '25

I want to learn how to access hardware in C. Which topics related to hardware and C should I learn (I have some basic knowledge on programming and computers)?

0 Upvotes