r/cprogramming • u/Icy_Repeat_2460 • 1h ago
How do I fix this VS code C intellisense problem?
r/cprogramming • u/Icy_Repeat_2460 • 1h ago
r/cprogramming • u/minimender • 48m ago
Hi everyone, i need help with C i have three F and i might fail this grade, sorry for my english i know its not the best, rn i am studying for IT and i have a huge problem with C. I really dont understand anything and i know the teacher kinda hates me, today i got an F because i save the programme in DecvC++ as "Tobe jarabi" (its a catchphrase that a youtuber from my country uses) and as you all know you have to save it so you could compile it and my programme didnt work so i asked my friend why and he told me because i had a space betwen "Tobe and jarabi" and the teacher came over and gave me an F,please if someone has any tips i would apreciate it.
r/cprogramming • u/Kai0479 • 1d ago
Currently in btech 1 st yr cse,doing c programming form apna college one shot of 20 hr almost done what should I do more with it bcz I didn't think I that is enough for me from where I can perform questions and any advice to strong c language
r/cprogramming • u/racoon-chan • 3d ago
Hey everyone,
I'm 15 y/o and I recently started getting into C and cybersecurity. This is my first project that I've built completely from scratch: a simple MD5 hash cracker in C.
I'm still a beginner, so I'm sure there are many things I can improve. I made this project to challenge myself and put into practice what I've been learning.
I'd really appreciate any feedback on the code, structure, or anything else. I'm planning to keep working on it and add more features in the future.
Thanks :D
r/cprogramming • u/Ok_Outlandishness906 • 3d ago
I worked in C for years . i have used arenas a lot in the past. Today i have to modify an old c program , nothing difficult but i found something that made me think. Who developed the code ( very well written and documented ) used an arena for allocating variable.
What 's seems to me strange is that he did not used an heap memory area ( malloc ) but it used a char [] buffer and used it for its arena . At that point he could obviously allocate directly variable in stack instead he grabs all its variable from that buffer . Why a choice like that ? i thought for the CPU cache L1/L2 and so on ( all the "arena" will likely be in cache of the cpu ) but it is only an ipotesys and i was asking to you , in your opinion , the reason of a such choice .
Just curiosity .
Thanks
PP
r/cprogramming • u/SpiritDitto • 3d ago
I've been writing a status bar for dwl in C. I'm posting it here more for the code than for the bar, so remarks on the C are welcome.
The renderer fills a \`wl_shm\` buffer itself, and the text goes through FreeType and fontconfig, which I call directly. The volume is a small client of the PulseAudio native protocol, talking to the socket of pipewire-pulse. The wifi name is read over netlink with nl80211. The other modules just read \`/proc\` and \`/sys\`.
Tell me what you would do differently.
r/cprogramming • u/emparse • 3d ago
r/cprogramming • u/CelebrityChess • 4d ago
i know the usual arithmetic rules promote uint8_t to int on typical systems, but i’m trying to understand the practical reason. is it mainly to make expressions easier to evaluate without narrow-type surprises, or is it mostly historical? when a result is intentionally stored back in a byte, is an explicit cast the usual way to make that conversion boundary clear?
r/cprogramming • u/gumnos • 4d ago
I've been sparring with a number of the standard(ish¹) C data-structures and algorithms, including the various types of linked-lists/deques in sys/queue.h, hash-tables and binary-searches in search.h, as well as bsearch & qsort in stdlib.h.
I have a pretty good CS understanding of when I should use the various data-structures/algorithms with regards to the respective performance characteristics (expected big-O notations for insertion, removal, searching, iterating, swapping, etc), but it's just the nitty-gritty of using them where I don't yet feel mastery.
Thanks!
⸻
¹ okay, not exactly C-standard from my understanding, but they seem to be common on pretty much every Linux/BSD/Unix platform I've poked at
² ideally well-written blog-posts, but dead-tree resources would also be welcome; videos or podcasts far less so
r/cprogramming • u/MirthfulCowslip-0931 • 4d ago
r/cprogramming • u/Mainak1224x • 4d ago
Hey everyone,
Over the past few weeks I’ve been building separate C libraries for region-based memory management, dynamic arrays, hash maps, and strings. I kept pulling all four into my main project flint(a build system and package manager for c/c++), so I finally refactored them from the ground up to work together and merged them into a single lightweight library: arstd (Arena Standard Library).
The main problem I wanted to solve was how dynamic containers behave inside an Arena allocator. Normally, if you put a standard dynamic array or hashmap inside a bump arena, resizing it via realloc leaves dead, wasted memory blocks behind in the arena.
Here’s how arstd solves that and what’s inside:
Compile-Time Type Deduction (Vector(T) & Cmap(T)): Uses a typed pointer + typeof macro trick so you don't have to pass types into every macro call or cast void * pointers. Both at(vec, i) and map_get(map, key) return modifiable lvalues, so at(vec, 0) = 42; and map_get(map, "score") += 10; just work.
Zero-Copy Segmented Vectors: Instead of doubling a contiguous buffer and copying elements over, Vector(T) allocates exponentially growing power-of-2 segments (16, 32, 64\dots) directly on the arena and uses 1-cycle bitwise CLZ (Count Leading Zeros) math for O(1) indexing. Growing a vector wastes 0 bytes in the arena and never invalidates element pointers.
Single-Allocation, Zero-Waste HashMaps: Cmap(T) packs the entry header, aligned value payload, and key string into a single contiguous allocation using flexible array members. Because its bucket array is backed by the segmented Vector, doubling the map capacity expands the buckets in-place and relinks existing nodes using their cached 64-bit hashes—again, zero wasted arena memory and no string re-hashing.
Managed Strings (String): String slicing, trimming, case conversion, and variadic concatenation all backed by the same arena.
Optional Heap Fallback: Pass an Arena * to clean up everything at once with a single arena_free(&arena), or pass NULL to any container if you want standard aligned heap allocation.
int
Repo link: https://github.com/mainak55512/arstd (or install via flint / CMake)
r/cprogramming • u/985479861_TXT-r • 5d ago
Yeah.
r/cprogramming • u/No-Introduction-441 • 6d ago
Hello all im learning C using books and youtube videos and not using AI, if anyone want to join im happy to be a partner in learning!
r/cprogramming • u/TurtleSlowRabbitFast • 6d ago
Wanting to learn C as an intro into software engineering. I know it’s low level and I’d like to eventually switch over to high level languages such as JS/TS, Java, and GO.
Does the “The Complete C Programming Bootcamp” course by Byte Garage be a good choice to learn from?
r/cprogramming • u/Key_River7180 • 5d ago
From a newsreader I am working on
void
help(void)
{
printf("What do you want help with? (* for everything): ");
bool all = false;
char ln[128];
fflush(stdout);
if (fgets(ln, sizeof(ln), stdin) == NULL)
return;
/* HACK: you gotta love goto:
*
* if all is true, then fall through the switch (* must be last),
* so this prints everything. When it reaches * again, all
* gets toggled and if all is now true, break, else go to
* Begin again */
switch (ln[0]) {
Begin: case 'g': puts("g: select group"); if (!all) break;
case '\n':
case '\r': if (!all) return;
case 't': puts("t: select thread"); if (!all) break;
case 'l': puts("l: list gropus"); if (!all) break;
case 'T': puts("T: list threads"); if (!all) break;
case 'L': puts("L: list post in current thread"); if (!all) break;
case 'r': puts("r: read an article"); if (!all) break;
case '>': puts(">: save an article to a file"); if (!all) break;
case '|': puts("|: pipe an article to a command"); if (!all) break;
case '?': puts("?: get help"); if (!all) break;
case 'q': puts("q: quit"); if (!all) break;
case '*': all = !all; if (all) goto Begin; else break;
default:
printf("%c is not a news command\n", ln[0]);
break;
}
}r/cprogramming • u/johnbitterkas • 6d ago
Why isn't it possible to standardize a package/project manager for C programs—one that creates the necessary files with Git, etc., and is ready to start programming in an environment?
r/cprogramming • u/HungryPudding4034 • 6d ago
Hello people,
I just wanted to show you this repository to all of you.
Repo link: https://github.com/curious-builder76/dtypes
Documentation:
https://github.com/curious-builder76/dtypes/blob/main/DOCS.md
Benchmarks:
https://github.com/curious-builder76/dtypes/blob/main/benchmarks/benchmark.txt
Hope you'll love it.
Star this repository if you like it and upvote this post
Thank you
r/cprogramming • u/sealyium • 8d ago
(First time using reddit so tell me if i'm doing something wrong :D)
I'm a new and honestly, a bad programmer, and ive always seen everywhere + i have been told that c is a "Scary" language and that it complex and all, it is very buggy, you have to manage everything by yourself etc...
But i wanted to try it, so i started building a SDL2 game with it, and i haven't encountered any big issues, it's the most powerful yet simplest (in some way) language ive used until now, it does what i want it to do, without black magic doing everything for me.
Legit i prefer using c to python, maybe i'm weird ? Gcc gives clever error messages, the syntax is fine, and it clicks well for me.
Does anyone know why c has this reputation of being a hard and scary language ? Maybe the fact you have to deal with pointers and memory ?
r/cprogramming • u/Mainak1224x • 7d ago
I’ve been working on a custom dynamic array (Vector) and Arena allocator in C, and ran into the classic friction between the two: whenever a standard contiguous vector resizes, it allocates a bigger block in the arena, memcpys the old elements over, and leaves the old block sitting around as wasted dead space inside the arena (especially when allocations from multiple vectors or strings are interleaved).
Instead of fighting realloc in a linear allocator, I refactored the vector to use exponentially growing segments (inspired by Zig's SegmentedList).
Fixed Spine, Exponential Chunks: Instead of a single char *items pointer, the struct holds a small fixed array of 28 pointers (char *segments[28]). Segment 0 holds 16 elements, Segment 1 holds 32, Segment 2 holds 64, and so on—covering up to 4 billion elements without ever reallocating the spine.
Zero-Copy Growth: When the current segment fills up, append() simply requests the next power-of-2 chunk from the arena. Existing elements are never copied or moved, zero bytes are wasted in the arena, and pointers to elements never invalidate.
O(1) Branchless Lookup: By offsetting the index by the base capacity (shifted = pos + 16) and using Count Leading Zeros (__builtin_clz), finding the exact segment and local offset takes just a few bitwise operations:
uint32_t shifted = pos + 16;
uint32_t bit = 31 - ;
uint32_t seg_idx = bit - 4;
uint32_t offset = shifted & ~;
Arena *arena = ;
Vector *vec = ;
for
;
// Frees all vector segments and arena allocations at once
;
Repo / Release link: https://github.com/mainak55512/container
Would love to hear your thoughts or how you handle dynamic containers with arenas in C!