Thread: File I/0

  1. #1
    Registered User NinetyFourGirl's Avatar
    Join Date
    Jun 2002
    Posts
    18

    Question File I/0

    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.

    Code:
    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);
    }
    Thanks

  2. #2
    Registered User
    Join Date
    Jun 2002
    Posts
    29
    Hmm.. I think that code which is using CDROM isn't for newbies..
    structs like cdtype or what you are using are too complicated for me (maybe I'm also a newbie..)

    I think you could write some simple programs..
    There is a lot of stuff about setting output form while using cout, I don't know it..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM