Hey, i need some help. i am currently writing to a file (using outfile) but i want to know whether you can open the file (using infile) before you send it to the outfile.
Thank you for your help.
Printable View
Hey, i need some help. i am currently writing to a file (using outfile) but i want to know whether you can open the file (using infile) before you send it to the outfile.
Thank you for your help.
mmmmm sounds like a simular problem im having, heres the email to a guy i know who might be able to help
Dave.Rees he teaches c++ in swansea
catch you later
Daz
Not sure I quite understand. If you have a file, you can read from it, and then write to it later, if you want. If you want to add on to the end of the file, you can use the ios_base::app flag when opening it:
fstream file;
file.open("file.txt", ios_base::app);
Files can come from anywhere. You can write them yourself using a text editor. They may contain data written from another program. They may contain data written from the current program. But whereever the data came from, if it is in the correct format, you can load it into your program where you can use the data in some fashion. You can then leave the data in the file unchanged, or change the data stored in the file by writing data from your program back to the file.
While the data is in your program it is held in a container of some sort. Containers can range in complexity from a primitive variable like an int, char or array or more complicated like a list or an instance of a user defined class or an instance of even be a more sophisticated container like a queue or a multimap or whatever.
The data held in the containers within your program doesn't have to come from files, either. It could be hard coded, input by a user, or be derived from a function within the current or other active program. However you obtain data for the containers in your program, what you do with the data within your program and how you handle the data after the after you are done with it is up to you.