Criticism of my programming?

Mainly simple stuff I've made. I would like some criticism to make my programming methods better. I would like some suggestions and comments on how I coded them.

BMI Calculator (Practice from book) - bmicalc.cpp
http://azimuthscpp.pastebin.com/f782ce027

Classes Practice (Circles) - classes.cpp
http://azimuthscpp.pastebin.com/f621503d7

Inches to Feet Converter (Practice from book) - inchToFeet.cpp
http://azimuthscpp.pastebin.com/f1fdb5e9a

Pointer practice (Storing integer in dynamic memory space) - memoryint.cpp
http://azimuthscpp.pastebin.com/f17f1d4c5

MPG Calculater (Practice from book) - mpg.cpp
http://azimuthscpp.pastebin.com/faa45ee2

Favorite Pie (Stores your favorite pie in a .txt file) - pie.cpp
http://azimuthscpp.pastebin.com/f1b3ff12b
pie.cpp@line 10: Buffer overflow by one element.

The rest are too short to criticize.
I don't know why It does that for you, it works perfectly fine here.
I don't need to test it. I'm telling you there's a buffer overflow.
pie is declared as an array of size 20. I.e. it contains elements [0..19]. On line 10 you're assigning to element 20, which is 1 element past the end.

Just because it works, it doesn't mean it's correct.
I don't know why It does that for you, it works perfectly fine here.


This is exactly why these kinds of bugs are so dangerous. The program may appear to work fine for months until it turns into a huge project, then all of the sudden the bug rears its ugly head and kicks your program's ass and is next to impossible to find.

Beware memory corruption!
Ooops. Thanks for pointing that out, I would never have noticed.
Topic archived. No new replies allowed.