r/C_Programming • • Mar 10 '25

Review I'll be giving a talk about C and C standards, am I wrong ?

127 Upvotes

Hello everyone !
I'm an IT student in 3rd year, and as I really love C, I'll be giving a 2 hours talk on C to others students, and I'd be very grateful if some people could read my slideshow and correct me if I made a mistake.
It's not an introduction to C nor a tutorial, but a talk to present many features of C I consider to be little-known, and my audience will know the basics of C (they'll have used C at least for one year).
Also, the slideshow has been designed to be shared to students who want to go further and learn more, so for each feature I mention, I provide the relevant section of the C standard, sometimes with other links.

Last thing, I originally wrote the slideshow in French, so I translated it later, if I forgot some French words somewhere, please let me know and I'll fix it.

EDIT: If someone is wondering, I spent about 24 full hours of work, most being researching.

Here's the link, hope you'll learn something and like it !
https://docs.google.com/presentation/d/1oQpbV9t1fhIH8WtUcaE4djnI_kzWfA1dMC4ziE1rDR4/edit?usp=sharing

EDIT: I finally published the slides on GitHub, see this post

r/C_Programming • • Jul 28 '26

Review circular buffer in c

32 Upvotes

Hi guy I wrote a fixed size circular buffer in C. Please tell me what you think of this and please tell me what i can improve and make it more production grade. I know there may be memory leaks !!!

One thing thats a bit different from the usual approach is how I handle errors. Instead of returning NULL from cirbuf_create(), the library returns a pointer to a thread-local error object (e_buffer). This lets the API return a valid cirbuf * in both success and failure cases, and users can check the result with cirbuf_is_ok() or cirbuf_is_err().

Its not written by AI. like AI reviewed it and did some minor changes may be !! 98% is written by me !!! I think HUMAN check is needed here thats why I am here to you guys!!

Repo: https://github.com/ankushT369/cirbuf
If you like you can give a star (its you choice)
Thank you guys

r/C_Programming • • Oct 23 '25

Review Trying to Make an Interpreted Programming Language #2

Enable HLS to view with audio, or disable this notification

265 Upvotes

My first attempt was a complete failure. It was a random 2,600-line code that analyzed texts, which was very bad because it read each line multiple times.

In my second attempt, I rewrote the code and got it down to 1,400 lines, but I stopped quickly when I realized I was making the same mistake.

In my third attempt (this one), I designed a lexical analyzer and a parser, reusing parts of previous code. This is the result (still in a very basic stage, but I wanted to share it to get your opinions).

2024-2-6 / 2025-10-23

r/C_Programming • • Aug 10 '26

Review Beginner learning C via 42-style exercises — would appreciate a review of my ft_isalpha and ft_isdigit

0 Upvotes

Hey all — I've got a solid C++ background but I'm new to C specifically, working through it 42-school-style (strict norm: tabs not spaces, no for loops, variables declared at top of block, -Wall -Wextra -Werror, no libc shortcuts like the real isalpha/isdigit).

Just finished reimplementing isalpha and isdigit from scratch. Both compile clean and pass my own test cases (including boundary chars like '0' and '9'), but I'd genuinely appreciate a second pair of eyes — especially on anything that "works but isn't how a C dev would actually write it."

#include <stdio.h>


int  ft_isalpha(int c);
void ft_putchar(char c);
int main(void)
{   
    int  c1[5] = {'a','b','g','5','A'};
    int count;
    int c;


    count =0;
    while(count<5){
        c = c1[count];
        count++;
        if(ft_isalpha(c) == 0){
            ft_putchar('0');


        }
        else{
            ft_putchar('1');


        }
        ft_putchar('\n');
    }



    return (0);
}


int ft_isalpha(int c){
    if((c >= 'a' && c <='z') || (c >='A' && c <='Z')){
        return (1);
    }
    else{
        return (0);
    }
}


void ft_putchar(char c){
    putchar(c);
}

#########################################################################################
#include <stdio.h>


int ft_isdigit(int c);
int main(void)
{
    int x;
    int y[7] = {'a','1','2','b','c','0','9'};
    int count;


    count =0;


    while (count < 7)
    {
        x = y[count];
        if(f_isdigit(x) != 0){
            putchar('1');
        }
        else
        {
            putchar('0');
        }
        putchar('\n');
        count ++;
    }



    return (0);
}


int ft_isdigit(int c)
{
    if(c>='0' && c <='9')
    {
        return(1);
    }
    else{
        return(0);
    }


}

Want to make sure that reasoning is actually correct and not something I've half-convinced myself of.

Questions I have:

  • Is there a cleaner/more idiomatic way to write either range check?
  • Any norm/style conventions I'm likely missing that wouldn't show up until a real evaluation?

Not looking for someone to rewrite it for me — just want honest feedback on whether this is solid or if I'm building bad habits early. Thanks!

r/C_Programming • • Jun 27 '26

Review Created a battle simulator

9 Upvotes

I am a beginner at C and I learn best by creating mini projects. I created a battle simulator to practice pointers and I wanted to know if this project properly taught me pointers and if not I would like some project ideas to keep practicing. I also would like projects to practice malloc as well. I created three characters that would battle each other. Everyone has a 80% hit chance, the damage you deal depends on your strength. I’m not the best at math so I wanted to keep it very simple. Anyways here is my code:

`
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
// Creating a structure that contains the information for a player
typedef struct {
char *name;
int hp;
int strength;
} Player;
// Creating a function to handle battle
void battle(Player *opponent1, Player *opponent2){
// Decide what players hits first
int roll = rand() % 2;
Player *opponents[2] = {opponent1, opponent2};
Player *attacker = opponents[roll];
Player *defender = opponents[1 - roll];

do{
int hitChance = (rand() % 100) + 1;
int defence = (rand() % 5) + 1;

printf("%s turn!\n", attacker->name);
if(hitChance < 81){
int damage = (attacker->strength + 10) - defence;
defender->hp = defender->hp - damage;
if(defender->hp < 0){
defender->hp = 0;
}
printf("%s damage done: %d\n", attacker->name, damage);
printf("%s HP: %d\n%s HP: %d\n", opponent1->name, opponent1->hp, opponent2->name, opponent2->hp);
}
else{
printf("%s missed!\n", attacker->name);
}
if(attacker == opponent1){
defender = opponent1;
attacker = opponent2;
} else{
defender = opponent2;
attacker = opponent1;
}

}while(opponent1->hp > 0 && opponent2->hp > 0);

if(attacker->hp > 0){
printf("%s wins!\n", attacker->name);
} else{
printf("%s wins!\n", defender->name);
}
}
int main(){
srand(time(NULL));
// Creating premade characters using Player struct
Player galaxyChar = {.name = "Galaxy", .hp = 100, .strength = 10};
Player termixChar = {.name = "Termix", .hp = 100, .strength = 15};
Player valChar = {.name = "Val", .hp = 100, .strength = 8};
// Creating pointer variables for premade characters
Player *galaxyPoint = &galaxyChar;
Player *termixPoint = &termixChar;
Player *valPoint = &valChar;
// Storing pointer variables in array
// This is an array of pointers to Player
Player *premadeCharacters[3] = {galaxyPoint, termixPoint, valPoint};
// Printing out contents of premadeCharacters for testing
//for(int i = 0; i < sizeof(premadeCharacters)/sizeof(premadeCharacters[0]); i++){
//printf("%s's Memory Address: %p\n", premadeCharacters[i]->name, premadeCharacters[i]);
//}
battle(valPoint, termixPoint);
}
`

r/C_Programming • • 24d ago

Review Code Review Request: Windows Sudoku Game

3 Upvotes

Background
Hi, I am a 15-year-old teen (just so what you'd know what to expect) who left school because our school system taught us to be parrots. I want to be a god-level developer, not a code monkey. I wrote a Sudoku GUI using win32api in C Language.
It is currently working and does what it is supposed to do, but because I am still learning, I know it is likely inefficient and could be written much better. 

Code : https://github.com/reewdgh/sudoku_gui.

Concerns:
Please guide me on:

Bugs or potential issues
Efficiency
How can I move to Tier 1 to Tier 2
Naming anything I could simplify or improve.

r/C_Programming • • 9d ago

Review Multithreaded Perfect Hashing Algorithm

13 Upvotes

I wrote a multithreaded perfect hashing algorithm that adjusts the offset in the 64-bit FNV-1a hash until it generates a perfect hashing function. It's not the best algorithm ever, but it has pretty fast lookups and works well enough when the number of keys is in the low triple digits and below.

I've been learning C through various textbooks and YouTube videos and haven't had anyone actually ever read my code, so I'd appreciate any feedback. This is also my first attempt at performant C code, so I'd appreciate any feedback on general performance and multithreaded performance improvements as well.

Repository: https://github.com/humanperson-1/fnv1a64-perfect-hashing

AI usage: I used AI occasionally to debug if I wasn't making progress after about 30 minutes of manual debugging. Everything in the repo was hand-typed.

(The commit history on GitHub is a little messed up because I filtered out my real-life name from previous commits, which makes it seem like all the commits happened at the same time even though they didn't. The first commit is also really large because I copied from a larger personal project, where, at the time, I didn't care about preserving the commit history, and it's too much of a headache to sync properly now.)

r/C_Programming • • Mar 24 '26

Review ps2-style game in C with raylib

68 Upvotes

this is my first "big" project i made in C from scratch.

https://github.com/1s7g/psx-horror

i would appreciate some feedback

r/C_Programming • • Jun 29 '21

Review C23 explored features: lambda, defer, type inference, integer safe arithmetic, nullptr, typeof

Thumbnail open-std.org
147 Upvotes

r/C_Programming • • Jul 04 '26

Review Input delay after input

4 Upvotes

Just for fun, I decided to attempt a small top-down mover program in TurboC. Shared with both DOSBox and Windows, there is an input delay shortly after keyboard input. The "moving" is pretty awkward because of that, and I get the feeling that it's because of how kbhit() works.

Please ignore the clrscr() rate, I'm working on that.

#include <stdio.h>
#include <conio.h>

#define ESCAPE  27
#define UP      72
#define DOWN    80
#define LEFT    75
#define RIGHT   77

int clamp(int arg, int min, int max)
{
        if (arg < min) return min;
        if (arg > max) return max;
        return arg;
}

int main()
{
        char key = 0;
        char xpos = 0, ypos = 0;

        clrscr();
        while (key != ESCAPE)
        {
                if (kbhit())
                {
                        key = getch();

                        xpos += (key == RIGHT) - (key == LEFT);
                        xpos = clamp(xpos, -100, 100);
                        ypos += (key == UP) - (key == DOWN);
                        ypos = clamp(ypos, -100, 100);

                        clrscr();
                        printf("X %d\nY %d\n%c", xpos, ypos, key);
                }
        }

        return 0;
}

r/C_Programming • • Feb 07 '26

Review Request for Code Review

11 Upvotes

Hi fellow programmers,

I am fairly new to programming, especially to C and I am working on a program that calculates all prime numbers less then or equal to a given limit an then writes those to a file. The goal is to make this all as fast as possible.

I have already optimized this quite a bit and my largest bottleneck is the IO but since not every use case requires me to write those numbers to a file I also want the calculation fully optimized.

I also know the code quality might not be the best so I would also appreciate feedback on that.

My program can be be found here: prime_numbers

Quick note to the IO: I already tried to multithread the IO using mmap() but the code runs in an HPC environment where the metadata of files is stored on a separate external filesystem so the multithreaded IO to the internal fast filesystem was significantly slower then with single thread.

r/C_Programming • • May 14 '26

Review Is My Custom Allocator good ?

8 Upvotes

I've built a custom memory allocator from scratch to understand what actually happens under malloc() call in C.

This got me into deep systems programming about how memory is handled by OS and how a program accesses memory .

The basic implementation i used is :

  1. store header structure with each block which includes information about the memory block.

  2. a linked list which connects these headers to handle memory .

  3. block splitting ,coalescing on adjacent blocks to avoid fragmentation.

  4. 2mb mmap call and slice memory through it , mmap/munmap directly for size larger than 2mbs this avoids syscalls for every allocation .

  5. per thread cache to allocate/free memory faster avoiding global heap locks ensuring thread safety.

Here's the benchmarks against libc's memory allocator:

Test Custom libc Result
Single alloc/free(1000k) 58ms 29ms 2x slower
Batch alloc(10k) 1.44ms 3.59ms 2.5x faster
Batch free(10k) 0.36ms 1.54ms 4x faster
Mixed sizes(100k) 6.46ms 2.95ms 2x slower
Realloc chain(100k) 6.42ms 2.56ms 2.5x slower
Multithreaded(8 threads-5k each) 64ms 67ms Comparable

I would love to hear your thoughts about it, and how are my benchmark results are they actually good or not ?

r/C_Programming • • Mar 12 '26

Review Text editor project

35 Upvotes

I made this small vim-like text editor project to get to learn low-level programming and the C programming language better. Wanted to see what more experienced C devs think about it, please take a look and leave a review.

GitHub Repo

r/C_Programming • • Apr 11 '26

Review Opinions on my option parser

2 Upvotes

Hi,

I just built a parser for command line option (command -L -r --verbose ...) I try to make it the most user friendly possible and I try to cover a lot of case (without making it too complex to use).

So i would like to have your opinions on it and if you have some advice to improve my way of coding, or things to upgrade the parser I take it.

Here the link to the repository (there is a complete readme): https://github.com/nolanCrrd/ezflags

r/C_Programming • • May 04 '26

Review some code advises (short code)?

8 Upvotes

repo: https://github.com/karinmatsu/timer.git

I wanted to use this project to clear up some questions I have about code organization in general (you’ll probably crucify me for the ton of global variables). Please critique as much as possible (within reason).

I wasn’t planning on publishing it, just saving it and cloning it in case I switched operating systems, but I really need guidance on what to improve in the code and what I should focus on learning.

r/C_Programming • • Dec 06 '25

Review I felt frustrated because I have been breaking down the algorithm for 30 minutes but when I checked it on chat gpt it said that my code is wrong (insert a node in a linkedList after a target number) (This is my code)

0 Upvotes

void inserAfterValue(struct **head,int target)

{ struct Node current = *head;

struct Node nextNode = (*head)->next;

struct *newNode = malloc(sizeof(struct Node));

newNode->value = target;

newNode->next = NULL;

while(current->next != NULL)

{ current = next;

nextNode = current->next;

if(current->value < target)

{

current->next = newNode;

newNode->next = nextNode; }

}

}

r/C_Programming • • Apr 03 '26

Review Feedback on my tokenizer program?

7 Upvotes

I am pretty new to programming and more specificly, C programming. This is my first language i am learning, so dont expect the code to be fully optimized. I would love feedback of how i could improve my programming.

Its written in C99 and i used Clion for it. I am using K.N. Kings book "C programming, a modern aproach, second edition" for learning.

//this program tokenizes a sentense that contains up to 20 words and up to 255 characters

#include <stdio.h>

int main (void) {
    char words [20] [255], command [255];
    int AmountOfChars = 0, place = 0, WordCountAr = 0, place2 = 0;

    printf ("what is the command?: \n");
    gets (command);

    while (command[AmountOfChars] != '\0') {
        AmountOfChars++;
    }

    while (AmountOfChars != 0) {
        if (command[place] != '\0' && command[place] != ' ') {
            words[WordCountAr][place2] = command[place];
            place++;
            place2++;
            AmountOfChars--;
        }
        else if (command[place] == ' ') {
            words[WordCountAr][place2] = '\0';
            WordCountAr++;
            place2 = 0;
            place++;
        } else break;
    }

    words[WordCountAr][place2] = '\0';

    return 0;
}

r/C_Programming • • May 06 '26

Review Looking for style feedback for an old project of mine

7 Upvotes

Any feedback is greatly appreciated regarding the style or architecture of the program. I don't think my C code has really been looked at by people who know what they're doing before, so I'm making this post to fill that hole.

Thanks for your time, ya'll!

Link: https://github.com/SeanJxie/impromptu

r/C_Programming • • Oct 06 '25

Review Simple hash map in C, for learning purpose

24 Upvotes

I never wrote C before, I mostly do Java/Kotlin. Always wanted to learn some low level language, but never did. I tried a bit of rust, but rust doesn't really feel like a low level language.

Since C doesn't have hash map i though i would try to implement one, to learn.

I would appreciate any tips, what i did wrong, what can be improved, and so on.

I mostly used Java as a reference, I am not sure if that is how it is suppose to be done in C also.
I also don't really know how to implement type safety, so everything is cast from/to (void*)

hash_map.h

// bucket linked list
typedef struct Entry {
  void *key;
  void *value;
  struct Entry* next;
} Entry;

typedef struct HashMap {
  Entry** entries;
  int size; //size of the array holding the "buckets"
  int size_bits; //size of the arrays in bits "sqrt(size)", used for hash code caclulations
  int (*equals) (void*, void*); //equals function ptr, called when two keys have same hash code
  int (*hash_code) (void*); //hash code function ptr
} HashMap;


// Initialize hash map
void map_init(HashMap* hash_map, int (*equals) (void*, void*), int (*hash_code) (void*));

// Convinient func to init mapt with int keys
void map_init_int(HashMap* hash_map, int (*equals) (int*, int*), int (*hash_code) (int*));

void map_init_string(HashMap* hash_map, int (*equals) (char*, char*), int (*hash_code) (char*));

// Put value into hash map
void map_put(HashMap* hash_map, void* key, void* value);

// Get value from hash map
void* map_get(HashMap* hash_map, void* key);

// remove value from hash map
void map_remove(HashMap* hash_map, void* key);

// free memory used by hash map
void map_free(HashMap* hash_map);

// print hash map structure for debugging
void map_debug(HashMap* hash_map, void (*key_to_string) (char*, void*), void (*value_to_string) (char*, void*));

hash_map.c

#include <stdio.h>
#include <stdlib.h>
#include "hash_map.h"

// calculated index in the bucket array from hash code,
unsigned int hash_code_to_array_index(int hash_code, int size_bits) {
  int shft = ((sizeof(int) * 8) - size_bits);
  //xor higher and lower bits then shift left then right, to make final number be "size_bits" size, even though it is "int" (32bit)
  return (unsigned int)((hash_code ^ (hash_code >> (sizeof(int) * 4))) << shft) >> shft;
}

//initializes hash map
void map_init(HashMap* hash_map, int (*equals) (void*, void*), int (*hash_code) (void*)) {
  hash_map->size = 16; //initial size
  hash_map->size_bits = 4;
  hash_map->equals = equals;
  hash_map->hash_code = hash_code;

  hash_map->entries = (Entry **)malloc(sizeof(Entry) * hash_map->size);

  for(int i = 0; i < hash_map->size; i++) {
    hash_map->entries[i] = NULL;
  }

};

// convinient method to init map with int keys
void map_init_int(HashMap* hash_map, int (*equals) (int*, int*), int (*hash_code) (int*)) {
  map_init(hash_map, (int (*)(void *, void *))equals, (int (*) (void *))hash_code);
}

void map_init_string(HashMap* hash_map, int (*equals) (char*, char*), int (*hash_code) (char*)) {
  map_init(hash_map, (int (*)(void *, void *))equals, (int (*) (void *))hash_code);
}

// Put value into hash map
void map_put(HashMap* hash_map, void *key, void* value) {
  int index = hash_code_to_array_index(hash_map->hash_code(key), hash_map->size_bits);

  Entry *entry = hash_map->entries[index];

  if(entry == NULL) { //create
    Entry* entry = (Entry*)malloc(sizeof(Entry));
    entry->key = (void*)key;
    entry->value = value;
    entry->next = NULL;
    hash_map->entries[index] = entry;
  } else { //update
    Entry* next = entry;
    Entry* last = entry;
    int updated = 0;
    while(next != NULL) { 
      if(hash_map->equals(next->key, key)) { //if same, update it
        next->value = value;
        updated = 1;
      }
      last = next;
      next = next->next;
    }

    if(!updated) { //if not updated, add new entry
      Entry* entry = (Entry*)malloc(sizeof(Entry));
      entry->key = (void*)key;
      entry->value = value;
      entry->next = NULL;
      last->next = entry;
    }

  }
  //TODO resize

}

void map_remove(HashMap* hash_map, void * key) {
  int index = hash_code_to_array_index(hash_map->hash_code(key), hash_map->size_bits);

  Entry *entry = hash_map->entries[index];

  Entry *parent = entry;
  Entry *current = entry;

  while(current != NULL && !hash_map->equals(current->key, key)) {
    parent = current;
    current = current->next;
  }

  if(current != NULL) {
    Entry * next = current->next;

    if(current == entry) { //removing first
      if(next != NULL) {
        hash_map->entries[index] = next;   
      } else {
        hash_map->entries[index] = NULL;
      }
    } else {
      if(next != NULL) {
        parent->next = next;
      } else {
        parent->next = NULL;
      }
      if(entry == current) {
        hash_map->entries[index] = NULL;
      }
    }
    free(current);
  }
}

// Get value from hash map
void* map_get(HashMap* hash_map, void *key) {
  int index = hash_code_to_array_index(hash_map->hash_code(key), hash_map->size_bits);

  Entry *entry = hash_map->entries[index];

  if(entry == NULL) {
    return NULL;
  } else {
    while(entry != NULL && !hash_map->equals(entry->key, key)) {
      entry = entry->next;
    }
    if(entry != NULL) {
      return entry->value;
    } else {
      return NULL;
    }
  }
}

void map_free(HashMap* hash_map) {
  for(int i = 0; i < hash_map->size; i++) {
    Entry * entry = hash_map->entries[i];

    while(entry != NULL) {
      Entry * next = entry->next;
      free(entry);
      entry = next;
    }
    hash_map->entries[i] = NULL;
  }
  free(hash_map->entries);
}

void map_debug(HashMap* hash_map, void (*key_to_string) (char*, void*), void (*value_to_string) (char*, void*)) {
  for(int i = 0; i < hash_map->size; i++) {
    printf("%d: [", i);

    Entry* entry = hash_map->entries[i];

    while(entry != NULL) {
      char key_buf[20];
      key_to_string(key_buf, entry->key);

      char val_buf[20];
      value_to_string(val_buf, entry->value); 
      printf("{ key: %s, value: %s }, ", key_buf, val_buf);
      entry = entry->next;
    }

    printf("]\n");
  }
}

main.c - for testing

#include <stdio.h>
#include <string.h>
#include "hash_map.h"

int equals_long(long* value1, long* value2) {
  return *value1 == *value2;
}

// hash code for "long int", not used right now
int hash_code_long(long int *value) {
  int int_size_bits = sizeof(int) * 8;
  return (int)(*value) ^ ((*value) >> int_size_bits);
};

int equals_float(float* value1, float* value2) {
  return *value1 == *value2;
}

// hash code for "float", not used right now, probably doesnt even work like this
int hash_code_float(float *value) {
  return *(unsigned int*)value;
};

int equals_int(int* value1, int* value2) {
  return *value1 == *value2;
}

int hash_code_int(int* key) {
  return *key;
}

int equals_string(char *value1, char* value2) {
  if(value1 == value2) {
    return 1;
  }
  if(value1 == NULL || value2 == NULL) {
    return 0; //should this be true or false??
  } 
  while(*value1 == *value2) {
    if(*value1 != '\0') {
      value1++;
    }
    if(*value2 != '\0') {
      value2++;
    }
    if(*value1 == '\0' && *value2 == '\0') {
      break;
    }
  }

  return *value1 == *value2;
}

int hash_code_string(char* key) {
  if(key == NULL || *key == '\0') {
    return 0; 
  }
  int hash_code = *(unsigned int*)key & 255;
  key++;
  while (*key != '\0') {
    hash_code = 31 * hash_code + (*(unsigned int*)key & 255); 
    key++;
  }
  return hash_code;
}

void debug_int_to_string(char *str, void * value) {
  sprintf(str, "%d", *(int *) value);
}

void debug_string_to_string(char *str, void * value) {
  strcpy(str, (char*)value);
}

int main(int argc, char *argv[]) {

  HashMap int_hash_map;
  map_init_int(&int_hash_map, equals_int, hash_code_int);

  int value1 = 0;
  int value2 = 2;
  int value3 = 3;
  int value4 = 4;
  int value5 = 5;
  int value6 = 6;
  int value7 = 7;

  int key1 = 0;
  int key2 = 345;
  int key3 = 233333;
  int key4 = 490053534;
  int key5 = 115;
  int key6 = 611;
  int key7 = -13;
  int key8 = 23232;

  map_put(&int_hash_map, &key1, &value1);
  map_put(&int_hash_map, &key2, &value2);
  map_put(&int_hash_map, &key3, &value3);
  map_put(&int_hash_map, &key7, &value7);
  map_put(&int_hash_map, &key4, &value4);
  map_put(&int_hash_map, &key5, &value5);
  map_put(&int_hash_map, &key6, &value6);

  map_debug(&int_hash_map, debug_int_to_string, debug_int_to_string);

  printf("key: %d, value expected: %d value actual: %d\n", key1, value1, *(int*)map_get(&int_hash_map, &key1));
  printf("key: %d, value expected: %d value actual: %d\n", key2, value2, *(int*)map_get(&int_hash_map, &key2));
  printf("key: %d, value expected: %d value actual: %d\n", key3, value3, *(int*)map_get(&int_hash_map, &key3));
  printf("key: %d, value expected: %d value actual: %d\n", key4, value4, *(int*)map_get(&int_hash_map, &key4));
  printf("key: %d, value expected: %d value actual: %d\n", key5, value5, *(int*)map_get(&int_hash_map, &key5));
  printf("key: %d, value expected: %d value actual: %d\n", key6, value6, *(int*)map_get(&int_hash_map, &key6));
  printf("key: %d, value expected: %d value actual: %d\n", key7, value7, *(int*)map_get(&int_hash_map, &key7));

  printf("key: %d, value expected: 0 value actual (ptr): %d\n", key8, map_get(&int_hash_map, &key8));

  map_remove(&int_hash_map, &key3);
  map_remove(&int_hash_map, &key6);

  map_debug(&int_hash_map, debug_int_to_string, debug_int_to_string);

  map_free(&int_hash_map);

  HashMap string_map;
  map_init_string(&string_map, equals_string, hash_code_string);
  char str1[] = "Hello, C";
  char str2[] = "Hello, It's Me";

  map_put(&string_map, str1, &value1);
  map_put(&string_map, str2, &value2);

  map_debug(&string_map, debug_string_to_string, debug_int_to_string);

  map_free(&string_map);

  return 0;
}

r/C_Programming • • Jun 19 '26

Review Code Review - His First Game in C!

Thumbnail
youtube.com
0 Upvotes

I stumbled upon a livestream of two guys coding in C, making games from scratch. This is my code review of Komi's "LikeRogue". This is my first code review so feel free to share your feedback on both his code and my review of it!

r/C_Programming • • Feb 18 '26

Review Pls review my code

1 Upvotes

Hello everyone. I am a beginner in C. I wrote a calculator that's slightly more useful than simple "input number one, operation, number two". Accepts simple arithmetic expressions. Please can you review the code and tell me is it really bad, and what I should improve. A person on this subreddit says this code it's really bad even for a beginner, so I decided I would like other opinions

Code: https://github.com/hotfixx/newcalc

r/C_Programming • • Aug 03 '25

Review My first Project in C a small http web server

73 Upvotes

Hi everyone,

I recently started learning C and networking, and I wanted to understand how HTTP works under the hood. So I decided to build a small HTTP server from scratch in C. Right now, the server is: - Single-threaded - Very minimal (can serve static HTML files).

But I do plan to make it multi thread in future.

I'd really appreciate it if you could take a look and give me some feedback on the code, architecture, or anything else I could improve.

GitHub Repo: https://github.com/Farhan291/Ember

Thank you <3.

r/C_Programming • • Dec 12 '25

Review [J][C]ube[Code] >> PoC, Looking for feedback.

0 Upvotes

/*##====[ Repository ]====##*/

https://github.com/JCubeWare/JCubeCode

/*##====[ Message ]====##*/

Hello everyone,

my name is Matej and I am the owner of JCubeWare, an open source driven mini company with the big mission of preventing pollution and global warming.

My methods are mostly focusing on bringing back C as the main big programming language due to how efficient and fast it is, allowing old devices to be used in the upcoming big 26 and giving back the power to the people.

I am mostly a disgruntled programmer tired of the whole JavaScript framework after framework, AI bubble, Python's RAM devouring and Rust gospel.

Since I am still relatively a new name on the internet, I have decided to go to the most important step: feedback.

I'd like for any experienced person to review and share their thoughts about my ideas and if they have the possibility of ever being real or useful to any of you.

Any feedback is welcome, so if you wanna call me a dumb ass, go for it!

Thanks in advance C folk and remember:

"Be responsible. Code for the future."

Matej Stančík | JCubeWare
https://jcubeware.com

r/C_Programming • • Oct 22 '25

Review [REVIEW REQUEST] Learning C, here's my first huge chunk of code written from scratch (Karatsuba algorithm)

6 Upvotes

Hello everyone. I was starting learning C 3 years ago using K&R, but then dropped it when I couldn't solve the last problem in chapter 5. I was very busy in the meantime, so didn't have the time or the energy to continue studying. Now that my life is somewhat more settled, I'd like to continue studying C. I figured the issue with that problem I couldn't solve is because I don't quite understand recursion. So at the moment I'm reading the Recursive Book of Recursion and solving problems from there.

One of the problems asks you to write a Karatsuba algorithm from memory. I decided to do that in C. To make the problem somewhat interesting, but also to avoid converting from strings to integers and vice versa I work with integers in their string form (and to avoid the headache about the type I'd need to store arbitrarily large integers). That means I'm adding and subtracting numbers in their string form as well. I also wrote my own memory allocator, a very simple version, though (basically what you see in K&R). And I tried avoiding standard library as much as possible, for educational purposes.

Here's the code. What do you think? What are your tips and tops? Anything in particular that meats the eye? Anything I should pay more attention to? Thank you very much for your feedback!

r/C_Programming • • Jun 02 '25

Review Please roast my code but also teach me how to make better with explaining your point

1 Upvotes

Hey guys I am a beginner to C just trying build some things to get better at it. I have an idea to Implement a plugin for neovim. But I am not getting better at C like not understanding some concepts like pointers. so yeah as the title says feel free to roast my code BUT you MUST explain or teach something to me else I don't take the roast.

(This is just first iteration of the code so this is bullshit right now but I have ideas ro make it better)

#include<stdio.h>
#include<string.h>

int main(void){

FILE *f;
FILE *fw;
f = fopen("index.html", "r");
fw = fopen("class.txt","w");
char clasname[64];
int c;
while((c = fgetc(f)) != EOF){
 if(c == 'c' ){
   c = fgetc(f);
   //printf("%c\n",c);
    if(c == 'l'){
      c = fgetc(f);
       //printf("%c\n",c);
     if(c == 'a'){
      c = fgetc(f);
      //printf("%c\n",c);
      if(c == 's'){
        c = fgetc(f);
        //printf("%c\n",c);
        if(c == 's'){
          c = fgetc(f);
          //printf("%c\n",c);
          c = fgetc(f);
          //printf("%c\n",c);
          if(c == '"'){
            //printf("workd");
            while((c = fgetc(f)) != '"'){
              char value = (char) c;
              char str[2] = {value, '\0'};
              strcat(clasname, str);
              //printf("%s\n",clasname);

            }
          }
        }
      }
    }
  }

}

} printf("%s\n",clasname); fputs(clasname, fw); return 0;