item index problem

Pages: 12
what I can see is, that it will certainly crash if you add more than 1 item to your inven. The same as order

what exactly are the steps that causes the crash with NetBean?
just get the crash when i use the function
 
void displayOrderRecord

other function work well and tried.

just the function when i play with 5-6 times. it crash
in readOrder() (you call that in callSystem()) you have

date = new char;

so you allocate space for one char

Here:

inFile.getline(date,9);

you read upto 9 chars. This means out of bounds.

So why don't you use string for date. It also means a memory leak.
but if string i cannot use the function of

1
2
string date;
_strdate( date );
alrready
because this function only available for char.
_strdate(date.c_str())
MiiNiPaa wrote:
_strdate(date.c_str())
No, it's const for a good reason:

http://www.cplusplus.com/reference/string/string/c_str/

You can do it like so:

1
2
3
4
string date;
char buf[100];
_strdate( buf );
date = buf;


consider using strftime() instead:

http://www.cplusplus.com/reference/ctime/strftime/?kw=strftime

which is standard in opposite to _strdate()
Topic archived. No new replies allowed.
Pages: 12