well, i was assigned my first project....but it's rather dull, so i decided to go WAY overboard on it.....
i created a random access file to store events for a calendar program..events contains the date and a description of it...
i'll try to post a little code as i can....i'm not asking you to find the bug...am i asking how i would find the bug...the biggest problem i'm facing is that i can't read the file (as a human)....
the output and description of the error is below the code.
int FileManager::addRecord(Record &srcRec)
srand(56); //really out of place, just haven't decided where
//to put it yet..i should probably use the time too
int openRecord = firstAvailable();
ofstream fout(filename, ios::binary);
fout.seekp(openRecord * sizeof(Record));
fout.write(reinterpret_cast<const char *>(&srcRec),
// i'm not planning on keeping this function, it's just for testing
while(fin && !fin.eof())
cout << endl << endl;
cout << "Key: " << cur_rec.getKey() << endl;
cout << "Date: " << cur_rec.getMonth()<<"/"<<
cur_rec.getDay()<<"/"<< cur_rec.getYear() << endl;
cout << "Label: " << cur_rec.getLabel() << endl;
cout << "Desc: " << cur_rec.getDesc() << endl;
the only record i added was the one with the key 221....
and for some reason it prints twice...i can't tell if this
is a looping error in the print, or in the write...