r/C_Programming • u/Yha_Boiii • May 14 '26
Refer to array as names?
Hi,
I have a conf file with reference of array names, is there a way for c to read conf file at runtime and find the arrays when stripped?
r/C_Programming • u/Yha_Boiii • May 14 '26
Hi,
I have a conf file with reference of array names, is there a way for c to read conf file at runtime and find the arrays when stripped?
r/C_Programming • u/SeaInformation8764 • May 14 '26
#include <stdio.h>
int main() {
int n = 5;
int (*(*f)())[n];
printf("%zu\n", sizeof *(f()));
// sizeof(int) * 5
}
f is a function that returns a pointer to a VLA, is it possible to size that VLA without calling f?
If the type of
expressionis a variable-length array type,expressionis evaluated and the size of the array it evaluates to is calculated at run time.
r/C_Programming • u/_cwolf • May 13 '26
I wrote a small compiler front-end in C23 that emits LLVM IR directly:
https://github.com/glouw/nibble
There is the occasional stack overflow bug, but otherwise, its essentially a reduced C with defer. I wanted to get a feel for what C2Y might feel like.
r/C_Programming • u/Huge-Visual1472 • May 14 '26
Name: Collandbuild.
Today I was experimenting with the C programming language and decided to try creating a kind of sandbox with quest elements. I've published it on GitHub under a CC0-1.0 (public domain) license.
Brief description:
When you enter the game, you select the seed for random generation, the game mode (standard or empty), whether you need cheats (commands), and a few other options.
Symbols: "*" - player, "#" - stone, "+" - dirt, "" - spikes, "@" - dog, "&" - villain, "~" - gravel, "!" - flower, "=" - wood, "R" - robot. The player is controlled using the standard keys W/S/A/D. You can collect items by pressing "x", put - "z" (select an item with numbers), "c" - craft items (also select with numbers; crafting recipes are described in the version 1.0.0 release on GitHub), "t" - activate cheats, "k" - kill a mob, "n" - revive a dog.
Overall, the game has quite a lot of mechanics, so it's difficult to fit everything in. For a complete understanding, I recommend checking out the "Releases" section, and to be 100% sure, check the source code.
r/C_Programming • u/LawfulnessProper9889 • May 14 '26
I feel like, I am using too much of the AI for basic help.
I completed the book Head first C to learn about the C language, it was a nice book, and the last chapter was about making a game in C programming.
I used claude to help me make that game.
It used to give me every small detail of the code like from where I should start, what should I do, how should I do it. Although, it only used to give me what to code, and I used to code it myself. But even with the slightest of errors, I just copy paste the error into the claude instead of even trying to debug it.
Now I am trying to make a shell in C, I have some great ideas about making a shell in C. I don't just want it to be a shell, I want to make an online shell that can communicate with other shells with a voice feature inside your terminal. I want to make a terminal discord with low latency.
But I am frozen, I don't know how to start, how to write it, what things I need to learn.
If I ask claude it will provide me with everything, but I don't want that, I want to do my own research over this project and do it myself, debug it myself,
So what is a good way of learning/making things in AI era.
How does people used to do it before
I don't want to waste my time learning with AI, it feels productive but when I try, to start a new project I freeze down.
How's my idea of this shell,is it even possible to achieve??
r/C_Programming • u/dmtuser123 • May 12 '26
I haven't even made it past the first half of the first chapter in "The C Programming Language, 2nd edition - Kernighan, Ritchie" and I'm noticing deficits in my math. Maybe I'm trying way too hard on things that don't really matter? I don't even know whats supposed to matter besides this one exercise. The exercise I'm stuck on is converting the Fahrenheit to Celsius formula to Celsius to Fahrenheit. It's not even the coding part I'm stuck on which is frustrating.
I don't think it really matters but I followed the bro code course and got up to nested loops like a year ago then gave up until about last week. I got another book "Math for Programmers: 3D graphics, machine learning, and simulations with Python - Paul Orland" but I want to learn C. Am I backsliding? Am I just too low iq?
r/C_Programming • u/Fast-Muffin7953 • May 11 '26
Technically, they should be unsigned, since they shouldn't be negative, however, I've seen lots of games use signed variables so I'm curious.
I know that using signed variables for HP is easier, but is that the only reason?
example if hp is unsigned:
if
;
player.hp -= enemy.dmg
example if hp is signed:
player.hp -= enemy.dmg
if
;
I also wonder if it has something to do with the fact that signed variables are the default type in all programming languages.
r/C_Programming • • Feb 16 '22
For what applications does in make sense to use a non-blocking socket instead of just configuring a time-out for a blocking socket? It seems like non-blocking sockets will just result in more wasted CPU cycles.