Hi everyone,
Please provide me some help on file reading and writing. First, I would like to know how to read data from a file and then write it to another file. I have been searching and seen examples of writing to the screen (Cout)only or writing some short strings to a file but not the whole data file from the input file.
Second, Is it possible to manipulate the writing by setting some conditions such as: If the word "ONE" appears in the file then do someting, "TWO" and "THREE" do something else ? as it can read a single character at a time only so how can it know the word "ONE, TWO or THREE" occur? We can use getword() or something but that people say it will cause errors (problem in new-line character).
ifstream OpenFile("test.doc"
char ch;
while(!OpenFile.eof())
{
OpenFile.get(ch);
cout << ch; //wrting to screen not to a file
}
OpenFile.close();
So how can we write what read from "test.doc" to another file"? Please help. Thanks
Please provide me some help on file reading and writing. First, I would like to know how to read data from a file and then write it to another file. I have been searching and seen examples of writing to the screen (Cout)only or writing some short strings to a file but not the whole data file from the input file.
Second, Is it possible to manipulate the writing by setting some conditions such as: If the word "ONE" appears in the file then do someting, "TWO" and "THREE" do something else ? as it can read a single character at a time only so how can it know the word "ONE, TWO or THREE" occur? We can use getword() or something but that people say it will cause errors (problem in new-line character).
ifstream OpenFile("test.doc"
char ch;
while(!OpenFile.eof())
{
OpenFile.get(ch);
cout << ch; //wrting to screen not to a file
}
OpenFile.close();
So how can we write what read from "test.doc" to another file"? Please help. Thanks