There is no need to use one file handle to read and write in different files. You can use fstream function to do this. Just look at following two steps.
Step 1 : First Open the file -> now Read the data -> now Close the file.
You can do this using following code.
Code:
#include<fstream.h>
int main()
{
char strs[32500];
fstream file_op("c:\\yogesh.txt",ios::in);
while(file_ops >> strs)
cout <
< strs ;
file_ops.close();
return 0;
}
Step 2 :Now open another file ->now write something to a file -> now close the file. You can do this using following code.
Code:
#include <fstream.h>
int main()
{
fstream file_ops("c:\\another.txt",ios::out);
file_ops<<"something Write to file";
file_ops.close();
return 0;
}
Bookmarks