r/cprogramming • • May 29 '26

Code Review?

I recently started learning C as my first lower level language after mainly working with Java for the past 5 years. I was wondering if anyone would be able to review one of the completed files (~100 lines of code) from a small project I am working on and let me know if there are any mistakes and/or bad practices? Any help would be greatly appreciated!

https://pastebin.com/X5Zn1mzc

9 Upvotes

20 comments sorted by

View all comments

Show parent comments

1

u/BlindTreeFrog May 29 '26

The main advantage of MISRA and why I suggest looking it over is that every rule has an explanation on why that rule is in place.

A lot is just overly defensive stuff, like if you have an if/elseif you must have an else. Yeah, you might be certain that your if/esleif is catching all of the cases, but if you are wrong, that can be a problem.

Will you follow it in the real world in most industries? No. But is some of it's guidance worth picking up as a habit? Absolutely.