Thread: file processing, delete certain data

  1. #1
    Registered User
    Join Date
    Nov 2003

    file processing, delete certain data

    would anyone help me to settle this function?
    for your information, i want to delete certain information from the database.

    example in the the database is name, address, and room number
    i just want to edit the room number of certain person from the database, anyone who know how to do that please tell me later.

    thanx in advance.

    void buyticket(int m){
    	fstream ticket("cruise.dat", ios::in | ios::out); //open patient's file
    		cout<<"File could not be opened to read."<<endl;
    	ship data;
    	ticket.seekg(   (m-1) * sizeof(ship)   ); *)&data, sizeof(ship));
    	cout<<"Available ticket : "<< data.return_room() <<endl;
    		int avalroom,befroom;
    		cout<<"Enter room : "<<endl;
    		cout<<"After : "<<room<<endl<<endl;
    		ticket.seekp(   (m-1) * sizeof(ship)   );
    		ticket.write((char *)&data,sizeof(ship));//write into the binary file
    		cout<<"Record Modified!"<<endl;

  2. #2
    Me -=SoKrA=-'s Avatar
    Join Date
    Oct 2002
    What you should do IMO is create a class or a struct with all the data you need for the person. Read everything into an array or a std::vector, change it there, and then overwrite the file with the modified data.
    SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
    I say what I say, I mean what I mean.
    IDE: emacs + make + gcc and proud of it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. Bitmasking Problem
    By mike_g in forum C++ Programming
    Replies: 13
    Last Post: 11-08-2007, 12:24 AM
  4. Writing and modifying data in a file
    By Micko in forum C Programming
    Replies: 2
    Last Post: 02-17-2005, 03:42 AM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM