r/cprogramming • u/[deleted] • Jul 05 '22
r/cprogramming • u/Windows2000Warrior • Aug 09 '26
Looking for people interested in advancing TheBrain
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:
🧠 A small decoder-only Transformer
🔤 A custom tokenizer and training pipeline
🏋️ Training and inference implemented directly in C89
🖥️ Native Win32 implementation
📦 PE analysis
🦠 Experimental malware-classification and anomaly-detection techniques
⚡ CPU-focused optimizations designed with older hardware in mind
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:
Improving the Transformer architecture
Experimenting with better datasets and training methods
Improving inference performance
Making the AI more capable while keeping it lightweight
Improving the PE analysis and malware-detection experiments
Exploring better classification or anomaly-detection approaches
Optimizing it for older CPUs and Windows 2000
Or simply experimenting with ideas that could advance the project
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/Nimesh1205 • Sep 12 '26
Want to build and learn stuff together?
Hi I am Nimesh, and I have learned many languages but now I want to focus specifically on a C programming language. I am in college 1st year and I need someone who can help me to fix problems and learn together with me. I know the good amount of C, not a professional yet but I know the fundamentals and I already knew some Leetcode patterns as I had solved around 240 questions on leetcode ( mostly easy and medium ) and 2-3 hard ones.
r/cprogramming • u/Steam_Liker_2002 • Nov 02 '26
Code initializer program.
To be honest, that's the best name I could think of.
You know when you start writing a file you have to type the usual
#include <stdio.h>
int main(int argc, char* argv[]){
return 0;
}Well this program makes it for you. It's may sound very simple, but at least it saves some time.
Source code:https://pastebin.com/yMj7njqC(Sorry github won't create an account for me, it says invalid domain?)
r/cprogramming • u/Free-Requirement5100 • Oct 18 '26
I've been building my own OS called VEX OS
Yo, so I've been working on my own operating system called VEX OS and thought I'd share it here.
The idea is to build an actual OS from the ground up, with its own bootloader, kernel, apps and eventually its own AI integrated into the system. I've been developing it in QEMU and I've managed to get it booting with stuff like a terminal and file explorer working. I'm also working on my own programming language called VexScript, which is part of the whole project. The AI side is called VEX AI. I'm developing that separately for now, but the plan is to integrate it directly into VEX OS rather than have it just be another app. Obviously, it's still a work in progress and there's a LOT left to do . I'm currently working towards getting VEX AI 1.5 integrated, then I want to make VEX OS bootable from a USB so people can try it out. I'm not gonna pretend it's anywhere near a finished product but I'm pretty happy with how far its come so far. What do you guys think, anyone else here working on their own OS or something similar?
r/cprogramming • u/ReplacementActive533 • Jul 03 '26
Please help me with my projects
I've built a C project with a clock-like system interface, but I'm very busy. Could the community help?
Link to my project: https://github.com/phuocthanhlamnguyen-gif/Time-system.git
You don't really need to follow the rules, but most of the rules are logical, and you can follow the license- not my rules, but it's optional, so I'll let you decide
r/cprogramming • u/Cheap_trick1412 • Nov 25 '25
Any good man can help me understand the prob and how to go on solving it ??
Implement dynamic circular queue in linux char device which takes data from IOCTL calls.
In Kernel Space:
IOCTL operations are:
SET_SIZE_OF_QUEUE: which takes an integer argument and creates queue according to given size
PUSH_DATA: passing a structure which contains data and it's length, and push the data of given length
POP_DATA: passing a structure same as above and just pass the length, while popping data in the structure can be random.
In user space:
Demonstrate the use of above char device, with sys IOCTL calls. Make sure to make this device blocking i.e. if there is no data passed while popping it should wait until other process pushes the data into the char device. The device should be /dev/<your_name>.
Example of the userspace driver:
-configurator.c
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#define DRIVER_NAME "/dev/vicharak"
#define SET_SIZE_OF_QUEUE _IOW('a', 'a', int * )
int main(void) {
int fd = open(DRIVER_NAME, O_RDWR);
int size = 100;
int ret = ioctl(fd, SET_SIZE_OF_QUEUE, & size);
close(fd);
return ret;
}
- filler.c
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#define DRIVER_NAME "/dev/vicharak"
#define PUSH_DATA _IOW('a', 'b', struct data * )
struct data {
int length;
char * data;
};
int main(void) {
int fd = open(DRIVER_NAME, O_RDWR);
struct data * d = malloc(sizeof(struct data));
d.length = 3;
d.data = malloc(3);
memcpy(d.data, "xyz", 3);
int ret = ioctl(fd, PUSH_DATA, d);
close(fd);
free(d.data);
free(d);
return ret;
}
- reader.c
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#define DRIVER_NAME "/dev/vicharak"
#define POP_DATA _IOR('a', 'c', struct data * )
struct data {
int length;
char * data;
};
int main(void) {
int fd = open(DRIVER_NAME, O_RDWR);
struct data * d = malloc(sizeof(struct data));
d.length = 3;
d.data = malloc(3);
int ret = ioctl(fd, PUSH_DATA, d);
printf("%s\n", d.data);
close(fd);
free(d.data);
free(d);
return ret;
}
Kernel driver should accept above IOCTL functions.
r/cprogramming • u/[deleted] • Dec 12 '24
What is the best language to learn right now
What is the best programming language to learn right now in order to fit well in the job market ?
r/cprogramming • u/78900sea • Jul 13 '26
Casino on c
Thanks to everyone . A special thanks to those who suggested the /dev/random - this very help for my tasks.
r/cprogramming • u/Massive_Mixture7652 • Nov 22 '25
Why c?
Hello so I have been learning c already been 5months but don't actually know what to do with it. You know there are too many options like system programming , socket programming and many more can anyone help me to choose , what should be criterias based on which I should choose a field , you know personal interest is just one of them.
r/cprogramming • u/w-AI-fu_DEV • Nov 06 '25
XSTD - Attempt at better C standard library, need feedback
Hey all, I decided to start working on my own standard library a while ago in April since I wanted to try out writing my own toy OS from scratch and without dependence on stdlib.
I was hot out of trying out Zig and Go for the first time, and I found that some design patterns from those languages would make for a good basis for what could become a better standard library for C.
Here are the points that I personally felt needed to be addressed first when writing XSTD:
- Explicit memory ownership
- No hidden allocations
- Streamlined error handling throughout the library (it even has error messages)
- Give users a DX comparable with more modern languages.
- Choice, as in choice for the developer to opt out of more strictly checked functions in order to maximize perfs.
Here is a simple example showing some of the more prominent patterns that you would see when using this library:
#include "xstd.h"
i32 main(void)
{
// Multiple allocator types exist
// This one is a thin wrapper around stdlib's malloc/free
Allocator* a = &c_allocator;
io_println("Echo started, type \"quit\" to exit.");
while (true)
{
// Read line from stdin
ResultOwnedStr inputRes = io_read_line(a);
if (inputRes.error.code) {
io_printerrln(inputRes.error.msg);
return 1;
}
// Memory ownership is explicit through typdefs
OwnedStr input = inputRes.value;
// Handle exit
if (string_equals(input, "quit"))
return 0;
io_println(input); // Print string with newline term
// Free owned memory
a->free(a, input);
}
}If you want a more meaty example I have a CSV parser example: https://github.com/wAIfu-DEV/XSTD/blob/main/examples/manual_parse_csv/main.c
Currently the features are limited to:
- Most common string operations, String builder
- I/O through terminal
- Buffer operations for bytes
- Math with strict overflow checking
- Arena, Buffer, Debug allocators obfuscated using the `Allocator` interface
- File operations
- HashMap, Typed dynamic List
- SIG hijacking
- Writer interface (for static buffers or growing buffers)
- (WIP) JSON parsing, handling and creation
I am not against major rewrites, and I'd like to have my theory clash against your opinions on this library, I believe that anything that doesn't survive scrutiny is not worth working on.
Please share your opinions, regardless of how opinionated they may be.
Thanks for your time, and if you are interested in contributing please contact me.
Here is the link to the repo: https://github.com/wAIfu-DEV/XSTD
r/cprogramming • u/Quick_Bee9308 • May 29 '25
Advice for a baby-coder(me)
Hey, I hope this post finds you well, i am in desperate need of advice. I am a Uni student currently about to tackle a C exam in 13 days. The exam will be 100% practical which means all the questions will be hands- on problem solving on the spot. My lecturer recommended This site called "Kattis" to practice on, apparently the exam questions will be similar to the 1-3 points difficulty problems on the site.
Anyways, I have an extremely hard time understanding the logic behind the sequence in which you code and the meaning themselves. I tried this course on sololearning "basics in C" took me 7 days cuz I was taking alot of notes, I finished it today thinking I gained theoretical knowledge but I came out feeling like knowing less somehow, especially about Pointers.
Everytime I try to solve a problem I end up doing 30% to 70% of the work then my brain short-circuits doesn't matter if comeback later i cant solve it, then I end up using Chatgpt to do the rest and chats solution makes perfect sense and I understand, yet I can't do it myself .
Idk what I should do now, do I keep brute forcing this problems on kattis until something clicks? Or maybe watch one of this 3 to 4 hours crash courses on YouTube?.
Thank you for your time and advice.
r/cprogramming • u/No-Introduction-441 • Nov 05 '26
Learning C from scratch – What projects should I build to become employable?
reddit.comr/cprogramming • u/mrkarki430 • May 06 '22
so if i input strings like:"ram" and "ramlal"
It show that both are equal but if i put "rami" and "ramo" it shows that "ramo" is greater. How can i solve this problem? Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char A[100],B[100];
int i,c=0;
printf("enter the first string;");
gets(A);
printf("enter the second string:");
gets(B);
while(A[i]!='\0'&&B[i]!='\0'){
if (A[i]>B[i]){
c++;
printf("the first string is greater;");
break;
}
else if (A[i]<B[i]){
c++;
printf("the second string is greater;");
break;
}
else
c=0;
i++;
}
if(c==0){
printf("both are equal");
}
return 0;
}r/cprogramming • u/Pointy_Peak • Apr 16 '22
Review 3 short C programs
Hello! Could any C programmers help evaluate my C programs which I had to write for an exam. Please send me a message or leave a comment if you can help, I would greatly appreciate your assistance.
r/cprogramming • u/[deleted] • Jun 21 '23
Q. To check whether a given string has any match with main string. Can you explain why the code below doesn't work and how to fix it?
include<stdio.h>
include<string.h>
int main() { char s[20],t[20]; int i,j,l1,l2; fgets(s,20,stdin); fgets(t,20,stdin); l1=strlen(s); l2=strlen(t); for(i=0;i<l1;i++) {j=0; if(s[i]==t[j]) { i++; j++;
} printf("%i",j); if(j==l2) { printf("match found at pos %i",i-l2+1); } } }
r/cprogramming • u/SmoothBeanMan • Jun 09 '23
Writing an algorithm to reduce matrices to their echelon form and I am stuck on this bit
void Reduce(int row, int col, double mat[][10])
{
for(int i=0; i<row; i++){
for(int j=0; j<col; j++){
mat[i][j]=(mat[i][j])/(mat[i][0]);
}
}
}
Good day. I have been working on this algorithm as a way to distract myself from studying but I am stuck on this function. The purpose of this function is the divide a whole row with the value of the first column in each row. The math seems sound to me but only the first value of each row is divided giving me 1s in the first column but without changing the values in subsequent columns.
I have attached the rest of the code below but this part up here is the important part. All other parts have been test and is working flawlessly
#include <stdio.h>
void test_print(double a[][10], int x, int y);
void INIT_Mat(double a[][10]);
void Get_row_col(int *a, int *b);
void Matrix_populate(int row, int col, double a[][10]);
void Division_numbers(int row, int col, double mat[][10], double nums[10]);
void test_print_1d(int row, double mat[10]);
void Reduce(int row, int col, double mat[][10]);
int main()
{
double Matrix[10][10];
double div_nums[10];
int row, col;
INIT_Mat(Matrix);
Get_row_col(&row, &col);
Matrix_populate(row, col, Matrix);
Reduce(row, col, Matrix);
test_print(Matrix, row, col);
return 0;
}
void Reduce(int row, int col, double mat[][10])
{
for(int i=0; i<row; i++){
for(int j=0; j<col; j++){
mat[i][j]=(mat[i][j])/(mat[i][0]);
}
}
}
void test_print_1d(int row, double mat[10])
{
for(int i=0; i<row; i++){
printf("%lf", mat[i]);
}
}
void Division_numbers(int row, int col, double mat[][10], double nums[10])
{
for(int i=0; i<row; i++){
nums[i]=mat[i][0];
}
}
void Matrix_populate(int row, int col, double a[][10])
{
for(int i=0; i<row; i++){
for(int j=0; j<col; j++){
printf("Enter value %d_%d: ", i+1, j+1);
scanf("%lf", &a[i][j]);
}
printf("\n");
}
}
void Get_row_col(int *a, int *b)
{
printf("Enter row count: ");
scanf("%d", &*a);
printf("Enter column count: ");
scanf("%d", &*b);
}
void test_print(double a[][10], int x, int y) //Test output
{
printf("Rows: %d\nColumns: %d\n", x, y);
for(int i=0; i<x; i++){
for(int j=0; j<y; j++){
printf("%.2lf ", a[i][j]);
}
printf("\n");
}
}
void INIT_Mat(double a[][10]) //This is used to initialize all values to 1
{
for(int i=0; i<10; i++){
for(int j=0; j<10; j++){
a[i][j]=1;
}
}
}
///////
r/cprogramming • u/boyricua • Feb 04 '23
Help with beginner C and Karel?
Any chance I could get some help in my DMs programming Karel in C? It’s my first coding class in C so it’s very basic. I have a sense of where my issue is I just don’t know where to go from here.
r/cprogramming • u/JazzyLev21 • Sep 05 '24
undefined reference to "stderr" on windows 11??
long story short, i have a C program that runs perfectly fine on my university's unix-based system that i connect to via ssh. however, after installing msys2 and all its components on my windows 11 laptop and adding it to my PATH variable, i am able to attempt compilation of the program, but get errors about undefined references to basic things such as fprintf, stdout, and stderr, all of which should work given that i've included stdio.h. i can't give specifics about the assignment because i don't want to violate my school's academic dishonesty policy, but here's the gist of what i'm trying to do:
fprintf(stderr, "insert string here");
fprintf(stdout, "insert other string here");i've spent a couple days searching for a solution on the internet to no avail. reddit is my last resort. is this some issue with windows itself?? why would stdout or stderr not be recognized?
r/cprogramming • u/moneyluckybunny • Feb 17 '24
Skyscraper puzzle
Hello,
Could any of you help me to solve a skyscraper problem in C pls🙏🏼🙏🏼 or if somebody already has done it it would be really helpful :))
r/cprogramming • u/Away-Fig-1207 • Feb 12 '24
How to printf the winner of a random number generator?
Hi there, I'm new to C programming and programming in general.
I'm trying to use a random number generator sorta as coin flip. I'm making a program where two teams face off and I'm confused on how to use the number to determine the winner. The teams are user input which is where I think I'm getting confused.
r/cprogramming • u/O1234561 • Oct 12 '21
Need help
I need to create a program that calculates answers for this function y=(3+sqrt(1-sqrt(x3)))/4-x2. It must be calculates by using starting value A, step H, step’s coefficient C and function upper limit YM. Conditions H>0 and C>=1 must be true and function value y will be calculated in the following points: A, A+H, A+H+CH, A+C+CH+(C2)H while y<YM but no more than 18 results. Can someone guide me as i have no idea how to do this, the only program ive managed to create all on my own was one that calculated perimeter of triangle by using coordinates of the tips. :)
r/cprogramming • u/NoSanaNoLife14 • Feb 07 '22
HUFFMAN
Hi, I'm doing compression and decompression in C but my output for my compression is not correct, may I know what's wrong with my code? Thank you so much :)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
FILE *file;
typedef struct node_t {
struct node_t \*left, \*right;
int freq;
char c;} *node;
struct node_t pool[256] = {{0}};
node qqq[255], *q = qqq - 1;
int n_nodes = 0, qend = 1;
char *code[128] = {0}, buf[1024];
node new_node(int freq, char c, node a, node b)
{
node n = pool + n_nodes++;
if (freq) n->c = c, n->freq = freq;
else {
n->left = a, n->right = b;
n->freq = a->freq + b->freq;
}
return n;}
/* priority queue */
void qinsert(node n)
{
int j, i = qend++;
while ((j = i / 2)) {
if (q\[j\]->freq <= n->freq) break;
q\[i\] = q\[j\], i = j;
}
q\[i\] = n;}
node qremove()
{
int i, l;
node n = q\[i = 1\];if (qend < 2) return 0;
qend--;
while ((l = i \* 2) < qend) {
if (l + 1 < qend && q\[l + 1\]->freq < q\[l\]->freq) l++;
q\[i\] = q\[l\], i = l;
}
q\[i\] = q\[qend\];
return n;}
/* walk the tree and put 0s and 1s */
void build_code(node n, char *s, int len)
{
static char \*out = buf;
if (n->c) {
s\[len\] = 0;
strcpy(out, s);
code\[n->c\] = out;
out += len + 1;
return;
}s\[len\] = '0'; build_code(n->left, s, len + 1);
s\[len\] = '1'; build_code(n->right, s, len + 1);}
void init(char *s)
{
int i, freq\[128\] = {0};
char c\[16\];while (\*s) freq\[(int)\*s++\]++;for (i = 0; i < 128; i++)
if (freq\[i\]) qinsert(new_node(freq\[i\], i, 0, 0));while (qend > 2)
qinsert(new_node(0, 0, qremove(), qremove()));build_code(q\[1\], c, 0);}
void encode(char *s, char *out)
{
while (\*s) {
strcpy(out, code\[\*s\]);
out += strlen(code\[\*s++\]);
}}
void decode(char *s, node t)
{
node n = t;
while (\*s) {
if (\*s++ == '0') n = n->left;
else n = n->right; if (n->c) putchar(n->c), n = t;
}putchar('\\n');
if (t != n) printf("garbage input\\n");}
int main(void)
{
int i, choice;
char \*str;
char ch;char buf[1024];
printf("Enter filename: ");
scanf("%s", str);if (file = fopen (str, "r"))
{
while (fscanf(file, "%s", &str[i]) != EOF)
{
i++;
}
}
fclose (file);
init(str);
for (i = 0; i < 128; i++)
if (code\[i\]) printf("'%c': %s\\n", i, code\[i\]);while(1){
printf("\n\n\tPick a Number");
printf("\n\t[1.] Compression");
printf("\n\t[2.] Decompression");
printf("\n\t[3.] Exit");
printf("\n\nEnter your choice: ");
scanf("%d", &choice);
switch(choice)
{
case 1:
encode(str, buf);
printf("encoded: %s\n", buf);
break;
case 2:
printf("decoded: ");
decode(buf, q[1]);
break;
case 3:
printf("\n\nThank You!");
exit(0);
}
}
return 0;}
r/cprogramming • u/FitDitto • Apr 14 '21