Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ofstream f1("h1.txt",ios::app|ios::out);
- if (!f1)
- {
- cerr<<"cannot open the filen";
- exit(-1);
- }
- currentPos = f1.tellp();
- cout<<"Initial Write Pointer Position = "<<currentPos<<endl;
- // Write some data at the end
- for(int index=0;index<20;index++)
- {
- f1<<index;
- }
- currentPos= f1.tellp();
- cout<<"Write Pointer Position after write = "<<currentPos<<endl;
- f1.seekp(10);
- currentPos= f1.tellp();
- cout<<"Write Pointer Position after seek = "<<currentPos<<endl;
- /** Note: Even if you reposition pointer, in app mode, data will always be written to the end */
- f1<<11;
- currentPos= f1.tellp();
- /** seekp does not match. In app mode, data is writtten to end */
- cout<<"Final Write Pointer Position after seek and write = "<<currentPos<<endl;
- f1.close();
Add Comment
Please, Sign In to add comment