r/cprogramming • u/LabAdministrative760 • 7d ago
Linguagem C Aula 21
Estrutura de Controle Condicional (if de via única) em C | Desafio de Adivinhação
r/cprogramming • u/LabAdministrative760 • 7d ago
Estrutura de Controle Condicional (if de via única) em C | Desafio de Adivinhação
r/cprogramming • u/Individual_Island_20 • 7d ago
If you download my game first and prove it was you, you'll get to give me ideas for two weeks. Your idea will 100% be added as long as it's realistic and possible to make. If an idea can't be done, I'll let you know where to share ideas/feedback — you can also message me on Reddit or in DMs.
Even if you aren't first, feel free to download and try it — it's not a virus, I promise. If you want, I can even record screenshots or videos showing how the game looks or how downloading works. Please, if you're the first to actually download it, reply so I know who was first (if five people download it at once, I won't be able to tell who clicked first).
Others can still share ideas too — they'll be considered, and I'll pass them to the first person (mentioning who wrote it) so that person can help decide if an idea gets added. If you suggest an idea, please explain how it would work.
If you don't speak Polish and really want something added, message me and I'll explain how the game works in English. Unfortunately, translating the game itself into English isn't planned right now because it would be tough to make. It's not a 3D game — it's a console game, and the visuals/images used are from the internet (not sure if any are AI, I didn't make them). Hope you enjoy! r/cpp r/cprogramming r/game
r/cprogramming • u/maith88 • 7d ago
r/cprogramming • u/Independent-Tune1860 • 7d ago
Guys I have question,
How the fuck can I learn c program in 5 days because my exam is coming in 5 days I m absolutely dumb guy and I don't have laptop as well as I m stroke patient since last 2 years where our 9 to 5 schedule is fully pack so I don't go in college and I don't have c language book as well I also want to learn matrix algebra, buisness mathematics, electronics their papers are also coming and I only their chapter
No student contact
No teacher contact
Only me and my fucking phone and you peoples
Please help me
(Btw I m doing graphic course in rehab because they provide us so that means I have 2 course 🥀😭 help meeeee)
r/cprogramming • u/Nonyabuizness • 9d ago
It has zero dependencies and is built entirely from C99 <complex.h> library. Anybody can use my library to write programs utilizing complex vector spaces be it Electrical Engineering, Signal Processing, Quantum Mechanics or even more.
I utilized single pointer flattened arrays for contiguous memory and cache efficiency.
I have included standalone example for every single function I have in my header file under the Examples/ folder.
I also built two pure C applications:
Check out my https://github.com/CodeLeverEuler/c-complex-linalg
I'm a freshman and this is my first systems/math library in C. Would love feedback on my API design, memory contracts, or numerical stability edge cases!
Thank you
EDIT:
Some are suspicious that this is AI generated. I didn't know that was an issue. I thought I wouldn't make my repository public until it's done.
I can't share the image from my local file here. But if anyone is having second thoughts, I have timestamps on my private Git repository and local files
r/cprogramming • u/Mainak1224x • 8d ago
Just added <cerror.h> to arstd (my C99 arena standard library) to bring Rust-style Result ergonomics to strict ISO C99—with zero compiler extensions (no typeof or statement expressions) so it compiles cleanly across GCC, Clang, and MSVC.
It includes typed Result wrappers, 3-arg and 4-arg TRY propagation, UNWRAP/EXPECT/UNWRAP_OR, and an optional custom error table with built-in CERROR_OK and CERROR_DEFAULT fallbacks:
;
;
ResInt
ResStr
Repo: https://github.com/mainak55512/arstd
r/cprogramming • u/Whole-Low-2995 • 10d ago
a basic practice, but it works quite well. It's good to attach some vim process to my current terminal. however, reptyr is totally okay though.
r/cprogramming • u/gabrielmfern • 11d ago
https://github.com/gabrielmfern/forbear
Hello! I've been working on forbear for almost 2 years now, and I've finally come around to implementing a proper C API for it! I would like to share here, and specially ask for some feedback on the API, and on how I wrote the macros that give it the DX I wanted for the library.
This is how it looks like:
void counter(void) {
fb_s64 *count = FB_STATE(fb_s64);
FB_ELEMENT(
.background = fb_color(fb_rgb(44, 49, 56)),
.border_radius = 6,
.padding = fb_all_sides(8),
) {
char count_text[64];
snprintf(count_text, sizeof(count_text), "count: %lld", (long long)*count);
FB_TEXT(count_text);
if (fb_on_click(FB_MOUSE_BUTTON_LEFT, true, false)) {
*count += 1;
}
}
}It's a dynamically linked library, with a single forbear.h header. To try it on Linux and macOS:
curl -fsSL https://forbear.dev/quick-start.sh | shon Windows:
irm https://www.forbear.dev/quick-start.ps1 | iexBeware that it's still quite experimental!
The main philosophy is to be what I envision the operating system should have provided us all along: a flexible on design, nice to write, performant, cross-language (in an idiomatic manner) and cross-platform way of making GUI programs.
I've written more about the process of making this C API here for anyone that might like to go more in depth https://www.forbear.dev/log/005-calculator-and-c-api.html
r/cprogramming • u/Far-Note6102 • 11d ago
Sorry for the newvie question but Im interested what do you prefer to use between the two?
r/cprogramming • u/Dear-Ad6656 • 11d ago
r/cprogramming • u/Seczu333 • 11d ago
How should i start learning C as my first language? Could anyone share some advice on where to start with C?
r/cprogramming • u/AegisRaspin • 12d ago
I've recently been looking into C and I want to start learning it, mainly because I am interested in how it works as a low-level language after using Python for a while, and eventually plan to take on Gentoo Linux and Linux From Scratch (with prior understanding of C and compilation). I welcome any advice!
r/cprogramming • u/antigravitys-rainbow • 12d ago
Hello friends, may I ask what is the difference between this subreddit and r/C_Programming ?
Thanks in advance
r/cprogramming • u/Individual_Island_20 • 12d ago
r/cprogramming • u/Consistent-Play-8932 • 13d ago
Hey folks,
I'm currently halfway through Stephen Brennan's classic "Write a Shell in C" (lsh) tutorial. It's a fun read so far, though it feels a bit too hand-wavy—it shows how to glue fork(), exec(), and wait() together, and leaves me itching for the actual official specs and deeper design docs.
It got me thinking about two things:
First, how did the OG legends like Ken Thompson or Stephen Bourne actually architect the early UNIX shells from a blank slate? I want to read the real foundational papers, POSIX docs, or historical design breakdowns instead of just toy tutorials.
Second—linking the classic Read -> Parse -> Execute loop to modern AI Agents—it feels remarkably similar to how agents parse context and dispatch tools.
Looking for recommendations on historical specs, papers, or minimal shell source repos. Drop them below!
r/cprogramming • u/Avi250 • 13d ago
Hello, everyone. I'm supposed to be doing a project for school (hence why I can't share the code), but I'll try to describe my problem to the best of my abilities.
My main parent process forks several children, who will execute 2 other programs, depending on the role assigned to them. Once the parent process receives a SIGALRM, it sends a SIGTERM to all its kids, and they, already having changed their signal handlers for SIGTERM, have to do whatever is specified in their signal handler.
Let's consider child A executes program A, and child B executes program B. These 2 processes have to communicate with each other through a series of msgsnd/msgrcv (we can only use System V IPCs in this project, so the msgops don't restart once interruped by a signal). A single process of type B will communicate with several processes of type A (but not with all at the same time: once its communication is finished with one, it goes on to the other). The last msgop A does, is a msgsnd and B does a msgrcv. I'd like to also add that, between the msgrcv and msgsnd on A's part, A is also supposed to go to sleep. A's almost entire program is in a while (it never terminates unless it receives the signal from its parent), whereas B terminates successfully once it's finished communicating with all the necessary A processes.
Whether B receives the SIGTERM signal or not, it has to modify sth in a shared memory section, but what it changes, depends on whether it has finished communicating with all the processes or not.
Ideally, I would like for B to terminate successfully, even if it receives SIGTERM, after having done all it had to do, and I thought of blocking SIGTERM with sigprocmask. That said, couldn't it still receive the signal between the mast msgrcv operation and sigprocmask? Is there any way whatsoever to make a set of instructions atomic?
I considered only having a sig_atomic_t volatile variable in the signal handler, which would increment if the the sign handler is executed, but then, not only would I have to continuously check in case it changed its value, but (and this could be me being wrong, please correct me if that's the case), B could still receive SIGTERM right after the condition of the variable being 0 is checked, and before the following instruction is executed (like a nanosleep - which I'd like to avoid if SIGTERM has been received - OR before a msgrcv, leaving B to wait for a message that will never come, because A could have received the same signal and will not be sending a message).
I thought of having the signal handler check a variable and act differently based on its value, but, again, maybe B receives the signal right before said variable's value changes. I also considered having an if where the conditions would be the variable==0 && msgrv(...)!=-1, but the variable can change after its value has been verified.
Disclaimer: we haven't studied sig_atomic_t volatile variables, so my knowledge might be lacking, although I did try to read up on them and research them. Also, the parent won't be deleting the IPCs until all kids have terminated.
Am I supposed to just hope for the best here and just proceed with sigprocmask? Is there another way I'm not seeing? Am I misunderstanding something? Any help offered is invaluable, so thank you in advance. I'm happy to answer any clarifying questions if I was unclear at all in the post.
r/cprogramming • u/CelebrityChess • 15d ago
i know a function parameter like int a[10] is really adjusted to int *a, so sizeof(a) inside the function gives 8 on my machine instead of 40. what i'm fuzzy on is why the language allows writing the size in the parameter at all if the compiler just throws it away.
is it purely documentation, or does it do anything with something like int a[static 10]? i've seen that form but never seen anyone actually use it.
r/cprogramming • u/Aggressive-Garlic722 • 14d ago
r/cprogramming • u/Icy_Repeat_2460 • 15d ago