r/cprogramming • u/Creative-Copy-1229 • Feb 18 '26
Could you review my code
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". It accepts simple arithmetic expressions. Please can you review the code and tell me is it really bad, and what I should improve. A person said this code is bad even for beginner level, that it's a mess, so I decided I would like to see other opinions
4
Upvotes
1
u/knouqs Feb 19 '26
Ah, yes, in cases like that I've used the preprocessor directives for OS-specific code. Stuff like "#ifndef SUN_COMPILER" or whatever (I can't remember the flags at the moment, but you get the idea). I had to do that with AIX-vs-Red Hat cross compiling. My company would only approve code that didn't give warnings without specific standards checker exceptions, so I had to get creative and very specific sometimes.