Input/Output project

Hello Peoplez :D
This is a homework given to us by our C++ teacher in school.

The program description:

This is a cable company program. The user would get a list at first. The list contains 3 choices; entering his data, changing color of the background, and exiting the program. When the user enters "1", the list should take him into a sub-list, where it should have 2 choices, he either is a residential customer or a business customer. After that he would get another list which has 4 choices. He would enter the data (like how many channels and stuff like that). This data will be saved inside a text file, in the following pattern (Name,data1,data2,data3,...etc) till all the data are written in there. Another choice in the list would be to delete an existing customer, and update an existing customer.

The shape of the program is pretty easy. Nothing but writing the codes i know. What I don't know is how I can delete data already written on the file, or update data already written on the file. Please help me with those. Thank you!!!
You have to read the entire file into memory, delete the entry you don't want or modify the entry you want, then write the entire file back out to disk.

jsmith I'm sorry but I had that idea just now when I read the tutorial about input/output, so you were not quite helpful because the code is my problem :(

Although, could you post the code? If not, is there a URL I can go to to help me? Other than the tutorial? Thnx a lot
Last edited on
bookzilla.org; they can supply you with helpful books... way better than tutorials!
jsmith (894) Dec 9, 2008 at 5:02pm
You have to read the entire file into memory, delete the entry you don't want or modify the entry you want, then write the entire file back out to disk.


Can you guys help me with the code to do that?

exception (307) Dec 9, 2008 at 5:18pm
bookzilla.org; they can supply you with helpful books... way better than tutorials!


I opened it but it was not in English.
Last edited on
Oh, right, this is a German site, sorry (it's my standard site for ordering books, since a part of their profit goes to the Free Software Foundation). But amazon.com also sells books... and has an English website. (Amazing, isn't it?)

Can you guys help me with the code to do that?

We could, but we won't. It's your homework, you are supposed to learn, but you won't if we take the possibility of doing it yourself away from you.
hannad, I assume you already know how to design the user interface using cin, cout, etc. You need to learn how to write code that does file I/O. Being a newbie like you, I only recently learned that by using Google and this site. Here are the sites I learned from:

http://www.cplusplus.com/reference/iostream/fstream/
http://www.cs.bu.edu/teaching/cs111/spring-2000/file-io/

That gives you all the tools and code examples you need to solve this problem, plus a lot more.
Last edited on
Thnx a lot Zettai Baka. I appreciate your help :D.
Topic archived. No new replies allowed.