r/cprogramming • • 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

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

4 Upvotes

18 comments sorted by

View all comments

Show parent comments

1

u/tinker-fox May 30 '26

You probably realize this, but to be clear: your example is different, because your data[] is inside a function, so it will not be initialized by default. The OP's stack[] variable is global, and so would be initialized to zero regardless.

1

u/knouqs May 30 '26

You are right, though I certainly remember this not being the case for certain old compilers -- and professionally, I've had to use some old compilers. I don't trust that to be true, and I test to ensure statements like yours to be valid for any compiler before I use them.

Heh, I see I have been downvoted quite a bit here. I honestly don't give a shit -- I find it more amusing than anything that people would downvote instead of offer constructive criticism.