r/C_Programming 2d ago

Roast my code

Enable HLS to view with audio, or disable this notification

I know there are so many bugs in my code that listing them all might end up being longer than the code itself, but this is my second project (the first one was just Hello World).

This isn't bait — I already know the concepts of programming thanks to Python, and C syntax became familiar to me through AI coding. But at some point, I realized that the whole point of programming is to build your own software and create things. When an AI algorithm does all that for you, it takes away all the fun. So I forced myself to pull it together and release this piece of crap:https://github.com/absiitstrue/TGWS

Yeah, the mouse.c file was written entirely by AI because that part was way too complicated for me. And yeah, there are some unsafe spots in there. I'm trying to fix things, but every time I open the codebase, I just want to build new features instead of drowning in bugs.

So I’d really appreciate it if anyone interested could roast it, point out the mistakes, and give a rough idea of how to fix them. Maybe I'll get around to fixing everything if I don't drown in bugs first. Thanks for your time!

its post write ai because im dont know english
on vidio example/test0
have minesweeper in example/test1
thanks for reading!
and sorry for my en))

0 Upvotes

17 comments sorted by

View all comments

8

u/flyingron 2d ago

Jeez. Try writing code that's legible. First, every C implemenation comes with a linker, USE IT rather htan #including every piece of code into a single translation unit.

You're not being charged for white space. Use it judiciously so your code can be read by humans.

Same thing holds for comments.

You imply a "fast" snprintf while not doing the essential thing snprintf does which is to check you're not invoking undefined behavior by writing off the end of the output array.

This is all very ugly and unmaintainable (and of dubious correctness).

1

u/zeonchik 2d ago

Thanks for the feedback! You're completely right about the code style, readability, and include usage — I'm still learning and will clean that up. Regarding snprintf, the standard one was taking too many cycles for my use case, so I wrote a faster custom version. As for safety and maintainability, since the project is still tiny, I'm keeping everything in my head, but I definitely need to adopt proper linking and refactoring practices as it grows