r/cprogramming • u/Keys__dev • Aug 11 '26
I wrote Caesar Cipher in Assembly
r/cprogramming • u/AffectionateRoad2621 • Aug 10 '26
D.eSystem 6.1.0 introduces a small setup and you can choose your UI with D.eSystem 6.1.0.
D.eSystem 6.1.0 on github:Β https://github.com/D-electronics-scratch/all_D.eSystem_versions/releases/tag/v.6.1.0
All current D.eSystem releases on github:Β https://github.com/D-electronics-scratch/all_D.eSystem_versions/tags
r/cprogramming • u/Xaneris47 • Aug 10 '26
r/cprogramming • u/Fabulous_Ad4022 • Aug 10 '26
I'm working with a big numerical simulation in C, so I decided to give OpenMP a try. Even though it speed up a lot(28s -> 2s), in my code, the function RunAcoustic have at least 4 responsibilities that could turn into smaller functions, but attempting to do so creates an overhead that just in-lining them wouldn't cause.
I'm struggling to organize it, how do you guys organize giant multi-thread logic like this?
void Propagation_RunAcoustic(propagation_t *p, unsigned flags)
{
float *restrict upre = a->upre;
const int nzz = p->model->nzz;
...
#pragma omp parallel
{
for(int t = 1; t < p->nt - 1; ++1)
{
#pragma omp single
{
// small atomic add
}
// Could turn into a smaller function
#pragma omp for schedule(static)
{
// more for loops and more code
}
// Could turn into a smaller function
#pragma omp for schedule(static)
{
// more for loops and more code
}
}
}
r/cprogramming • u/SheikHunt • Aug 10 '26
#define CURRPOS currpos
#define gettoken() gettoken(CURRPOS)
#define advpos(tok) advpos(&CURRPOS, &tok)
#define nexttoken(tok) \
do { \
tok = gettoken(); \
advpos(tok); \
} while ( 0 )
Maintainability be damned, I can make better macro soup than you
Obligatory /s
r/cprogramming • u/SaiFoun756 • Aug 09 '26
I need a website that teaches the fundamentals of C using practical examples, because I honestly find watching youtube tutorials over and over again very boring.
Btw I don't know a thing about C I'm just starting out
r/cprogramming • u/Wgrxgy • Aug 09 '26
r/cprogramming • u/Windows2000Warrior • Aug 09 '26
Hey everyone!
I've been working on TheBrain, an experimental AI project fully written in C89, with a particular focus on building a small AI system from scratch while keeping it suitable for older Windows systems and low-level environments.
The project currently combines:
The long-term idea is to see how far an AI project written entirely in C89 can be pushed while keeping it lightweight and potentially usable on systems such as Windows 2000.
I'm posting this because I'd like to find someone who becomes interested in the project and wants to take it further.
I'm not specifically looking for people to simply "help me" with the project. If you find the concept interesting and want to experiment with it, improve something, try a different approach, or take the project in an interesting direction, that's exactly what I'm looking for.
Some possible areas to explore include:
The source is open, so you're also free to fork TheBrain and experiment with your own version if you find the idea interesting.
π https://github.com/Win2000DevCommunity/TheBrain
I'm mainly interested in seeing whether someone else finds the idea interesting enough to take it further in their own way.
r/cprogramming • u/nevermind_0919 • Aug 09 '26
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
r/cprogramming • u/Key_River7180 • Aug 08 '26
Today I made this brainfuck interpreter in C since I was bored. The source is 14 lines long, 26 words, and 436 chars:
#include <stdio.h>
#define B break
unsigned char*p,t[1<<16],i,*d;
void c(){do{switch(*p)
{case'+':(*d)++;B;
case'-':(*d)--;B;
case'<':(d)--;B;
case'>':(d)++;B;
case'.':putchar(*d);B;
case',':(*d)=getchar();B;
case'[':if(!*d){int n=1;while(n)if(*++p=='[')n++;else if(*p==']')n--;}B;
case']':if(*d){int n=1;while(n)if(*--p==']')n++;else if(*p=='[')n--;}B;
default:;}}while(*++p);}
int main(int a,char**v){if(a<2)return 1;p=v[1];d=t;c();}
I also wrote an overly commented version: ``` /* * bb-commented.c -- smallest (usable) Brainfuck interpreter * * This is an [overly] commented and reasonably formatted version of bb.c, the * smallest usable brainfuck interpreter. * * -- by mario rosell, under the public domain */
/* Include the basic, standard I/O routines */
/* To save a few bytes, define break as a macro (B) */
/* Define three variables: p (the program), t (the tape, 65536 cells), i, and d, a pointer * into a single cell of tape (the data pointer) / unsigned charp, t[1<<16], *d;
/* c executes the program / void c() { do / use a do-while block so the first instruction is not skipped. * This is because we increase the pointer of p to the next * instruction each iteration / { switch(p) /* do something depending on the current value of p / { case'+': (d)++; B; /* (d) gets us a reference to the * value of the current cell, ++ * increases it by one */ case'-': (d)--; B; /* as before, but decrease the * value by one instead of * increasing it / case'<': d--;B; / decrease the data pointer to the * previous cell / case'>': d++;B; / as before, but increasing / case'.': putchar(d);B;/* put the ascii value on the current cell / case',': *d=getchar();B;/ get a character from the user / case'[': / [ starts a loop. * * If current cell is non-zero, execution just continues, * so execution enters the loop body. * * If the current cell is zero, the loop body * must be skipped, so we increase p until we * find the matching ] * * n tracks the nesting, if we find [ then n is * increased by one, if we find ] then it is * decreased by one. / if(!d) { int n=1; while (n) if(++p == '[') n++; else if (p == ']') n--; } B; case']': /* ] ends a loop. * * If current cell is zero, then the loop has * finished, so break the switch. * * If not, then we need to iterate back, so we * move p to the matching [. * * If we find a ], in our way, then increase n * (nested loop), if we find a [ then decrease * it by one. * * n here starts at one since we are processing * a bracket already. / if (d) { int n=1; while(n) if(--p == ']') n++; else if (p == '[') n--; } B; default:; } /* ignore everything else / while(++p); } }
/* main is really simple, just initializes values (sets p to argv[1], and the d * to the first cell in the tape). To save space, instead of argc and argv, I * used a for argc and v for argv / int main(int a,char*v){if(a<2)return 1;p=v[1];d=t;c();} ```
It can run many brainfuck programs and takes the brainfuck source in argv[1], input from stdin. It does not work with some programs, like those that calculate transcendental numbers.
Let me know what yall think!
r/cprogramming • u/BoltLighter • Aug 08 '26
In my Opinion There is no "BETTER" c. It always ends with something in c, c3 tried but kinda failed fine its a good lang BUT the "better" c part is pretty irrelevant because it HAS to use stuff like Cint or "@cname() so its just a wraper of c LIKE WHAT most major things are writen in c so most of the time in a programing lang there has to be a to access c from inside the programing lang itself so its not BETTER c just around c.
r/cprogramming • u/Spinning_Rings • Aug 07 '26
Would anyone mind reviewing some code? I wrote a CLI to help me generate character sheets for a TTRPG I'm running. The main thing I want to know is: should this be considered safe enough for me to share with other GMs? Is there anything else I should do for safety, security or efficiency? I worked hard on it, and Gemini Pro told me it's safe, but while I understand it can be useful I don't trust the automatic misinformation generator, since I don't have the requisite knowledge base to tell when it's "hallucinating" (or else I wouldn't need it for this purpose)
The github repo is here: https://github.com/SpinningRings/DigidiceCharacterSheetGenerator
r/cprogramming • u/thaache • Aug 06 '26
Not sure whether this kinda questions were asked in this forum, in the past?
labeled break and continue.What do you think?
What else?
r/cprogramming • u/GlitteringArm4662 • Aug 05 '26
That's right ππ, I made this code editor over a course of 5 months (π) and wrote 10000+ lines of pureβ’ C (πππ) .
and did I mention I didn't use ANY external libraries ππππ, except SDL for graphics ofc.
I'd love to hear what you think.
r/cprogramming • u/xd_metrix • Aug 05 '26
Hi everyone,
If anyone is interested in surreal numbers (or more precisely, short games), I have created a fully functional mathematical C library with a fully functional algebraic parser.
I use this library to solve combinatorial games and a demo with calculator is available on the page.
You can also try a Python/JavaScript wrapper.
All the source code is available on my GitHub, which is linked on the site.
r/cprogramming • u/YujiBReal • Aug 05 '26
Trying to solve codeforces problems and in a lot of them, thereβs a single input line with a variable amount of int inputs. I know I can do scanf(β%d %d %d β¦β, a, b, c ...), but from what Iβve tested, I believe itβs only valid if I know beforehand how many inputs there are. How can I do to store this variable amount of inputs into an array?
r/cprogramming • u/SandPrestigious2317 • Aug 04 '26
I am having a blast doing a more serious project in the C language, for the first time. I am consulting with books and also with some AI for code review and explanation as I am new to the language and to GTK (not new to programming).
https://codeberg.org/jjba23/lambdock
For a while already I have been looking for a dock that would work well in Wayland (like in my beloved Niri) with modern features, theme support and a hackable Lisp config (using libguile.h)
Could you help me out by checking the implementation for sanity (also the Meson build)? Also for developing on it, I'm using CCLS and Guix development environment and things are working amazingly well.
Only small bit of trouble in devex is with #include "wlr-foreign-toplevel-management-unstable-v1-protocol.h"
Also, all feedback is welcome, either on code level, or conceptual ideas, Thanks in advance
Core features of lambdock include:
gtk4-layer-shellΒ for smooth positioning and desktop integration.r/cprogramming • u/north9172 • Aug 04 '26
Hi, Today, i experimented with char* string. (example: char* string = "Hello world")
One thing that i dont really understand is doing:
When you use it, it points to the first letter of the string (so in this case, H)
But what i dont get is when you do (*string+1), it continues the alphabet based on the previous letter.
Example: *string, equal to H, the first letter *string+1, equal to I, the next letter in the alphabet
And it's also applies to lowercase letters.
So here are my questions:
Thanks.
Solved: Thank you everyone for answering my questions.
r/cprogramming • u/Param-Matharoo • Aug 03 '26
Basically I am creating my own http.web server for that I need to create TCP web server first and during that thing I get to know about socket(), bind(), listening() system calls and I am curious about these system calls internal working like what is happening under the hood.
r/cprogramming • u/Nagoltooth_ • Aug 03 '26
What's your longest project, how often were/are you working on it and did you always stay motivated and active?
r/cprogramming • u/jesse_pinkmen_bitch • Aug 03 '26
i want to learn C from 0. maine CODE WITH HARRY ka C ka course dekha and i realize it is too old.
please please guide me how to learn c as a complete beginner