I know this is probably a stupid question... but I've only just started with c++ this year and I'm working on a File I/0 summative. Anyway, this code is almost right out of the textbook and it's for a program that is supposed to keep track of cd's. How can I change this function so that it reads the cd with the title specified by the user instead of the cd number (RecNum)? The code in the textbook does not seem to be working.
ThanksCode:bool ReadCD(fstream&F, const long RecNum, CDType&CD) /*Reads record RecNum into CD Pre: F is open for reading Post: CD contains record RecNum false returned if the read fails, otherwise true returned*/ { if ((RecNum < NumRecords(F)) &&(F.seekg(RecNum*MaxRecSize))) { getline(F, CD.Location); getline(F, CD.Album); getline(F, CD.Artist); getline(F, CD.Status); return(true); } else return(false); }



LinkBack URL
About LinkBacks



(maybe I'm also a newbie..)