Hi.. i'm trying to write a program for my assignment with add, display all, search edit and delete functions.. but I'm stuck with edit and delete... I've been searching online and found out that you need to use 2 files to do it.. I got the part to remove and rename,but my problem is getting the program to detect the record that i want deleted...i saw some where about using pointers or something? but Im not sure how to use it... The records are all in string btw.. Please, can someone help me in the right direction? Thanks!
Sorry about that.. I guess in summary, what I need to do is to be able to delete a record from a file.. The user will enter the code of an item, and that record will be deleted.. Can you show me how to do it please?
Just open the file you want to delete a record from in read mode, read it into some format you can work with and then close the file. Delete the record from that format, open the file again in write mode, write the data back to the file, and then close it again. Done.
hanst99 (1456) Sep 13, 2011 at 7:34pm
Ah, I suppose that makes it clearer.
Just open the file you want to delete a record from in read mode, read it into some format you can work with and then close the file. Delete the record from that format, open the file again in write mode, write the data back to the file, and then close it again. Done.
Sorry, But you lost me at
read it into some format you can work with
... What do you meand by that? im still quite new to c++...so far I havent come across anything in my book that talks about formats? o_o
"Format" is just a concept, it doesn't refer to anything specific of the C++ language. What I mean is, if you have a file that stores a bunch of integer values, you would put those into a std::list<int> for example.