r/cprogramming

I am open-sourcing csv.h a single-header CSV parser written in pure C99
▲ 94 r/cprogramming+1 crossposts

I am open-sourcing csv.h a single-header CSV parser written in pure C99

For my thesis I had to read a lot of big CSV files in C and I couldn't really find a parser I wanted to use. The main C one is LGPL and comes with a whole build system, and everything else I found was C++. So I ended up writing my own. Now that im done with the thesis i cleaned it up properly , seperated it from the rest of the thesis code, and decided to standalone push it on GitHub.

It's one file. You copy csv.h into your project and that's it, nothing to link, no dependencies. It doesn't allocate memory, the fields just point into your own buffer, and you can run through files of any size a chunk at a time.

Honestly I spent way more time testing it than writing it. It passes csv-spectrum and I compared the output against Python's csv module on a few thousand files/

Check it out here -> https://github.com/GeorgeKiritsis/Csv.h

If someone has time to look at the API and tell me what could change or be imrpoved, that would help a lot. Thanks a lot in advance

u/giorgoskir5 — 1 day ago
▲ 3 r/cprogramming+3 crossposts

grm: telegram CLI project in C++

grm: telegram CLI that is Human and AI friendly repos:

Features:

  • Dual Human/AI UX Engine: Optimized both for interactive terminal use (ANSI TTY tables, color schemes) and automated AI agent workflows (JSON envelope, NDJSON streams).

  • Native TDLib Engine: Direct C++ bindings to libtdjson for zero-hallucination, full MTProto protocol fidelity.

  • Supergroup & Forum Topic First: Complete lifecycle management for Telegram Supergroups, Forum Topics, custom emoji icons, and thread messages.

  • File Upload & Download Engine: Streamlined document, photo, video, and media extractions with MIME detection and progress tracking.

  • Shell Tab Auto-Completion: Context-aware Bash tab completion covering commands, subcommands, flags, and options.

  • Telegram Rich Text & Emoji Customization: Telegram Markdown V2 entity formatting and custom Supergroup topic emoji icons.

  • FreeDesktop & XDG Compliant: Strictly honors FreeDesktop standards for user binaries, man pages, shell completions, and session state.

Im just having fun with it. I have a roadmap so check it out. I'll see how much time I can dedicate to this one.

It's already pretty cool, at least for me. The --filter and --since options are killers.

It's pre alpha stuff. Use it under your own peril.

I had to compile my own libtdjson and put it in ~/.local/lib:

$ ldd ~/.local/bin/grm 
	linux-vdso.so.1 (0x00007f69897ba000)
	libtdjson.so.1.8.0 => /home/someuser/.local/lib/libtdjson.so.1.8.0 (0x00007f6987400000)
	libjson-c.so.5 => /lib64/libjson-c.so.5 (0x00007f698976b000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f6987000000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f69872e9000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f698973e000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f6986e07000)
	libssl.so.3 => /lib64/libssl.so.3 (0x00007f6986d0e000)
	libcrypto.so.3 => /lib64/libcrypto.so.3 (0x00007f6986600000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f6989712000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f69897bc000)

Login works at least... sometimes. ;D

Demo:

$ time grm chat ls
CHAT ID              TYPE            TITLE                          UNREAD
---------------------------------------------------------------------------
-1003950065700       Supergroup      Domadores Digitales            0
-1002549279967       Supergroup      EVALinux Bar!                  0
-1002312480906       Supergroup      NorTK                          0
-1002289735000       Supergroup      EVALinux                       0
-1003981300643       Supergroup      (expert) creations             1
-1001623037840       Supergroup      Linux En Español               9
-1002527874209       Supergroup      Fundación MxOS                 0
-1001981848857       Supergroup      NubeMX                         0
-1003679369169       Supergroup      Hyper Muscles & Boobs Heaven   36
8911035898           Private Chat    Abastero                       0
-467666877           Basic Group     Proyectos 1101                 0
-1003596396470       Supergroup      1101 SOPORTE VALLEJO           0
-1001371756065       Supergroup      Fedora Linux                   3
6943468991           Private Chat    Doris Marian Jiménez Beltrán   0
777000               Private Chat    Telegram                       0
-1001127772209       Supergroup      DeviantArt                     0
-1001382463627       Supergroup      Team Offtopic buscando popularidad en el barrio del baneado 0
-1002234007248       Supergroup      Naomilk 🐰🔞                   0
-1001100311770       Supergroup      Fedora México                  0
-1001789902965       Supergroup      Los Bonitos                    1

real	0m0.063s
user	0m0.047s
sys	0m0.030s

$ time grm msg ls --filter='@renich' --limit=2 --since='3 years ago' -1001100311770
(2023-08-16T00:39:26Z) <@renichbon> : Ah, un comando para resetear todas mis configuraciones de GNOME:
                                      
                                      dconf reset -f /
                                      
                                      
                                      Úselo bajo su propio riesgo.
(2023-08-26T23:26:58Z) <@renichbon> : OpenTF Foundation
                                      https://opentf.org/announcement
real	0m0.484s
user	0m0.045s
sys	0m0.025s

real	0m0.484s
user	0m0.045s
sys	0m0.025s
u/Renich — 1 day ago

This is going to sound dumb, but what order does the C preprocessor execute tasks in? (First includes, then defines etc)

This sounds dumb, but when the C preprocessor executes tasks as it reads source code, what order does it process the tasks in -- for example, does it handle include files first, then defines, then macros etc?

I know it all gets done eventually, but it would seem the order defines what is seen. If defines are done first and includes are inside a define, then they never get read. If I were building my own preprocessor, what order should I execute steps in:

  • Include files
  • Convert everything except quoted strings to lower case
  • Strip comments
  • Do defines/not-defines

Or is this really my fault for putting to many "compiler tasks" into the pre-processor? Is the correct answer "Don't make the pre-processor do anything other than includes and defines"

reddit.com
u/Rich-Engineer2670 — 3 days ago
▲ 0 r/cprogramming+2 crossposts

Made a video explaining how memory ACTUALLY works in C++ (Stack vs Heap, new/delete) — feedback welcome

Hey everyone,

I put together a video on Dynamic Memory Allocation in C++ — part of an OOP series I'm building for people prepping for interviews/DSA who want solid fundamentals, not just surface-level definitions.

Covers:

  • Stack vs Heap — the real differences, not just textbook definitions
  • Why taking array size as user input on the Stack is a bad idea (and often breaks across compilers)
  • How new actually allocates on the Heap at runtime
  • Why you need a pointer on the Stack to access Heap data
  • Using delete properly to avoid memory leaks

I tried to explain the "why" behind these concepts since most tutorials just show syntax without explaining what's actually happening in memory.

Link: https://youtu.be/JxrYh3xUF54

Would love feedback — anything unclear, anything you'd want covered next in the series (constructors/destructors, virtual functions, etc.), or just general thoughts. Not trying to spam, genuinely want to make this series useful.

Thanks!

u/Silver_Court_3399 — 3 days ago
▲ 11 r/cprogramming+4 crossposts

Bodeg.a | El directorio Binario

Hola, muy buenas tardes. Soy desarrollador, en su mayoría de soluciones nativas. Constantemente, cuando programo en C o C++ (entre otros), experimento la incomodidad de tener que compilar cada una de las dependencias, lo cual en ocasiones es frustrante: algunas vienen sin siquiera un archivo de compilación decente o compatible, y otras tienen dependencias difíciles de compilar o pesadas. Es por ello que quise crear una pequeña plataforma.

Se trata de Bodeg.a (un juego de palabras entre bodega y el .a de los binarios estáticos tipo UNIX). Su funcionamiento es bastante sencillo: más que una plataforma con alojamiento de archivos pesados, es (por ahora) una simple web donde se pueden realizar publicaciones con un mirror con la intención de que apunte a un archivo .zip, un header o el formato que sea necesario.

Por ahora no ofrece hosting mas que para lo esencial (avatares y perfiles), pero de tener buena recepción eso podría cambiar. Si eres desarrollador, te gusta o solo trabajas con el bajo nivel, el simple hecho de intentar usarla para descargar contenido de ella me ayudaría muchísimo; o si quieres colaborar con su desarrollo, también puedes contactarme. ¡Saludos a todos!

bodeg-dot-a.vercel.app
u/23ROMAN — 5 days ago
▲ 8 r/cprogramming+1 crossposts

Beginner using C Programming a Modern Approach

I understand the problem but the error message I do not understand the error message

Write the following function:

bool search(const int a[], int n, int key);

a is an array to be searched, n is the number of elements in the array, and key is the search

key. search should return true if key matches some element of a, and false if it

doesn’t. Use pointer arithmetic—not subscripting—to visit array elements.

`Here is my solution:

bool search(const int a[], int n, int key) {

int *p;

for (p = a; p < a + n; p++) {

if (*p == key) {

return true;

}

}

return false;

}

`

I get an error message of 'assignment discards ‘const’ qualifier from pointer target type'

I remove the const from the parameter list and the program works fine. Can yall explain what the error message means. I am compiling with gcc btw i dunno if that helps. sorry for bad formatting im kinda new to this.

thanks

reddit.com
u/Scared-Objective3768 — 5 days ago

Arr internals

i am currently working through kinds book on c and have gotten to chapter 12.

now based own my current understanding i hypothesis that internally, only the pointer to the first element and the dimensions are stored in memory. then all arr operations are done using this. Is this correct?

Additionally:

  1. Which chapters of the rest of the book should i focus on/skip for now

  2. I would like to work on some projects. Currently i thought of making some kind of physics sim, and additionally some hardware/embedded project as i have an ardiuno. How can i get started or are there any inriguing projects to work on.

reddit.com
u/SmileUnfair4978 — 5 days ago
▲ 42 r/cprogramming+7 crossposts

Kwipu, a fully-local MCP server that turns your Obsidian/Markdown notes into a queryable knowledge graph (runs on Ollama)

Ask questions across your Markdown notes using a fully local Graph RAG engine. Built for Obsidian vaults, works with any folder of Markdown files. Extracts entity-relation triples from wikilinks & YAML frontmatter, retrieves answers via hybrid search (vector + BM25 + temporal). Multilingual. No cloud. Runs on Ollama.

https://github.com/benmaster82/Kwipu

u/WritHerAI — 7 days ago

What is the right way to write and debug a program?

I am preparing for DSA, and I find it difficult to debug arrays inside a function. When I enter the function in the debugger, I can only see the starting address and the value of the first array element. I am not able to see the other array values. What is the right way to debug this, and how should I write the program to make debugging easier?

This is sort01 code fro example:

debugging image : [debug.png](https://postimg.cc/JGfZ8jrd)

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

void sort01(int *array, int n)
{
    int tmp=0;
    int left=0;
    int right=n-1;
    while(left &lt;= right)
    {
        if(array[left] !=0)
        {
tmp = array[left];
array[left]= array[right];
array[right]=tmp;
right--;
        }
        else
        {
            left++;
        }
    }
}
int main()
{
int array[]={1,0,1,1,1,0,0,1,0};
int n=sizeof(array)/sizeof(array[0]);
sort01(array, n);
for( int i=0 ;i&lt;n ; i++)
printf( "%d",array[i]);
return 0;
}
u/sudheerpaaniyur — 7 days ago
▲ 20 r/cprogramming+1 crossposts

Generic hash table with optional ordering

Hi. For the past few weeks I've been crafting my generic hash table implementation:

https://github.com/andrzejs-gh/ghtable

I realize it's not the fastest out there and isn't the most cache friendly, but that was never my priority as I prioritized flexibility and genericness.

If anyone's interested take a look ;)

PS.

Do recruiters even care about projects like this nowadays, or would they rather see huge vibecoded codebases on candidate's gh as a proof that they can deliver?

u/lehmagavan — 8 days ago

seriously, how do you easily find ansi/vt100 key codes?

right now im writing a short little text editor, and requires me grabbing keyboard input as traditional ansi escape sequences. but finding which key code maps to which keyboard input is a pain for me </3

i try search on google, and get a lot of information overload, and i end up struggling reading the escape sequence tables.

any tips and advice? im trying not to use ai to be lazy, im interested and i want to learn how to properly search for these codes

reddit.com
u/No_Beyond_5483 — 8 days ago

You may not like it, but this is what peak programming looks like

#define CURRPOS currpos
#define gettoken() gettoken(CURRPOS)
#define advpos(tok) advpos(&amp;CURRPOS, &amp;tok)
#define nexttoken(tok) \
do { \
tok = gettoken(); \
advpos(tok); \
} while ( 0 )

Maintainability be damned, I can make better macro soup than you

Obligatory /s

reddit.com
u/SheikHunt — 11 days ago
▲ 7 r/cprogramming+2 crossposts

I built a lightweight C++ Memory Scanner &amp; Pointer Chain Resolver (HexaCore)

Hey everyone,

I wanted to share a project I've been building: HexaCore, a lightweight memory scanner and tool built from scratch using C++ and the Win32 API.

Key Features:

  • Multi-level pointer chain resolver & scanner
  • Array of Bytes (AOB) scanning with wildcard support
  • Built-in Hex Viewer, basic Disassembler, and NOP/Patch tool
  • Custom dark UI with card-based panels and adjustable freezing intervals
  • Cheat table save/load system

It's open-source. I'd love to hear your feedback or suggestions for the V1 version!

GitHub / Source Code: https://github.com/abuzit/HexaCore-Memory-Tool

u/Wgrxgy — 9 days ago

Where to learn C program?

I want to learn C programming,plz suggest some good websites or youtube channels where I can learn C language.I prefer smtg that's similar to MOOC which is for python from university of Helsinki.Plz drop your suggestions

reddit.com
u/nevermind_0919 — 11 days ago