Guest User

Untitled

a guest
Aug 15th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. Operations on file | get and put pointer
  2. MyFile . seekg ( 0 , ios :: beg ) ;
  3. MyFile . seekp ( -10 , ios :: end ) ;
  4.  
  5. index :0 1 2 3 4 5 6 7 8 9 10 ... -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0
  6. __________________________________________________________________
  7. ^ ^
  8. ^ ^
  9. ^ ^
  10. get Pointer put pointer
  11.  
  12. Myfile . get ( character ) ;
  13. MyFile . write ( SomeString, 4 ) ;
  14. MyFile . flush ( ) ;
  15.  
  16. index :0 1 2 3 4 5 6 7 8 9 10 ... -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0
  17. __________________________________________________________________
  18. ^ ^
  19. ^ ^
  20. ^ ^
  21. get Pointer put pointer
  22.  
  23. FileIN . seekg ( 1, ifstream :: cur ) ;
  24.  
  25. FileIN . seekg ( 1, ios :: cur ) ;
  26.  
  27. index :0 1 2 3 4 5 6 7 8 9 10 ... -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0
  28. _____________________________________________________________________
  29. ^ file-pointer
  30.  
  31. MyFile . seekg ( 0 , ios :: beg ) ;
  32.  
  33. index :0 1 2 3 4 5 6 7 8 9 10 ... -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0
  34. _____________________________________________________________________
  35. ^ file-pointer
  36.  
  37. MyFile . seekp ( -10 , ios :: end ) ;
  38.  
  39. index :0 1 2 3 4 5 6 7 8 9 10 ... -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0
  40. _____________________________________________________________________
  41. ^ file-pointer
  42.  
  43. Myfile . get ( character ) ;
  44. // you must sync/flush if your last operation was input and you switch to output,
  45. // or your last operation was output and you switch to input.
  46. MyFile . sync ( ) ;
  47.  
  48. index :0 1 2 3 4 5 6 7 8 9 10 ... -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0
  49. _____________________________________________________________________
  50. ^ file-pointer
  51.  
  52. MyFile . write ( SomeString, 4 ) ;
  53. MyFile . flush ( ) ;
  54. index :0 1 2 3 4 5 6 7 8 9 10 ... -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0
  55. _____________________________________________________________________
  56. ^ file-pointer
Add Comment
Please, Sign In to add comment