Nov 29, 2012 at 3:42pm UTC
This program crashes at the end and i have no idea why :( I want it to transform my .txt file into a .bin file it makes the file correctly and everything but it has a fatal crash at the end. Anyone got any clue?
using namespace std;
struct item z;
fscanf(fp,"%d %d %d %d %d %d %d ",&z.id,&z.power,&z.aim,&z.time,&z.value,&z.armour,&z.bars);
Nov 29, 2012 at 5:05pm UTC
Try checking to see if the file pointers are valid before you use them.
Nov 29, 2012 at 7:14pm UTC
you could try putting a condition in your j for loop. as it now stands, it could over run the allotted character buffer.
also, are you sure of the consistency of the itemDB.txt file? any irregularities in that could cause problems, including containing less than 38 lines.
the scanf family of functions are very error prone.
Nov 29, 2012 at 7:33pm UTC
That code looks like C, altough it has included C++ headers like iostream, which is never used.
Nov 30, 2012 at 3:23am UTC
its c code implemented in c++ code.