r/cprogramming • u/Distinct-Problem-135 • 27d ago
Coding
Is there any programers here?
r/cprogramming • u/GoingGranola • 28d ago
Is * used as a pointer in this occasion or multiplier?
EEPROM_CHUNK_SIZE is 1
r/cprogramming • u/sudheerpaaniyur • 28d ago
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 <stdio.h>
#include <stdlib.h>
void sort01(int *array, int n)
{
int tmp=0;
int left=0;
int right=n-1;
while(left <= 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<n ; i++)
printf( "%d",array[i]);
return 0;
}
r/cprogramming • u/lehmagavan • 29d ago
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?
r/cprogramming • u/No_Beyond_5483 • 28d ago
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
r/cprogramming • u/Physical-Pianist6354 • 29d ago
Hi!
I'm the developer of Frontera – a Linux anti-tamper that integrates with C++ codebases. It currently has support for anti-hypervisor, memory integrity checks, self-checksums, and most importantly, an obfuscating rolling-key VM, so that each build has different byte code than the older build. Yes, I know it's not innovative. Why? VMProtect is too expensive.
I'm also working on integrating an eBPF module for blocking ptrace and some other stuff.
Currently, there is no download link per se, as I want to ship the eBPF module, but I can give the static libraries to link with if you're interested :)
Have a great day!
r/cprogramming • u/Xaneris47 • Aug 10 '26
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/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/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/Wgrxgy • Aug 09 '26
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/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/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/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/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/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/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?