Guest User

Untitled

a guest
Jan 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. ofstream f1("h1.txt",ios::app|ios::out);
  2. if (!f1)
  3. {
  4. cerr<<"cannot open the filen";
  5. exit(-1);
  6. }
  7. currentPos = f1.tellp();
  8. cout<<"Initial Write Pointer Position = "<<currentPos<<endl;
  9. // Write some data at the end
  10. for(int index=0;index<20;index++)
  11. {
  12. f1<<index;
  13. }
  14.  
  15. currentPos= f1.tellp();
  16.  
  17. cout<<"Write Pointer Position after write = "<<currentPos<<endl;
  18. f1.seekp(10);
  19. currentPos= f1.tellp();
  20. cout<<"Write Pointer Position after seek = "<<currentPos<<endl;
  21.  
  22. /** Note: Even if you reposition pointer, in app mode, data will always be written to the end */
  23. f1<<11;
  24. currentPos= f1.tellp();
  25.  
  26. /** seekp does not match. In app mode, data is writtten to end */
  27. cout<<"Final Write Pointer Position after seek and write = "<<currentPos<<endl;
  28. f1.close();
Add Comment
Please, Sign In to add comment