I'm not new to C++ programming. Just trying to review my programing skills so I tried to create a program that will compute for the BMI (Body Mass Index) and produce a Patient Report (That will contain the information of all patients). There will be a auto generating Patient No. So if it's the first time you run the program, the patient number will be zero. But if you run the program again, the patient number should be the last patient number (let's say the last patient is number 5, so the next time I run the program, the patient number will be number 6). I used the file "PatientReport.txt" to get the last patient number and increment it so that I can get the next number.
I'm using MS Visual Studio 2010 PRO....
So I got it (quite) working... The first time I run the program, it runs perfectly... But when I tried to run it again, yes I can still run it... but when I tried to exit the program, a error window appears with this note "Run-Time Check Failure #2 - Stack around the variable 'autonumber' was corrupted." if i continue, it shows the buffer overflow error
When I looked at the debug notes I can see
pr 0x53b4e4f8 {_ptr=0x00000000 <Bad Ptr> _cnt=0 _base=0x00000000 <Bad Ptr> ...} _iobuf * |
There's a 0x00000000 <Bad Ptr> at _base _ptr and _tmpfname with CXX0030: Error: expression cannot be evaluated
I hope that anyone here can help me solve this Stack around the variable 'autonumber' was corrupted error