Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

File Pointers

12,978 views

Published on

Published in: Technology, Education
  • Writing good research paper is quite easy and very difficult simultaneously. It depends on the individual skill set also. You can get help from research paper writing. Check out, please ⇒ www.HelpWriting.net ⇐
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • If you’re struggling with your assignments like me, check out ⇒ www.WritePaper.info ⇐. My friend sent me a link to to tis site. This awesome company. After I was continuously complaining to my family and friends about the ordeals of student life. They wrote my entire research paper for me, and it turned out brilliantly. I highly recommend this service to anyone in my shoes. ⇒ www.WritePaper.info ⇐.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating direct: ❤❤❤ http://bit.ly/2F7hN3u ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating for everyone is here: ❶❶❶ http://bit.ly/2F7hN3u ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

File Pointers

  1. 1. FILE HANDLING IN C++
  2. 2. STREAMS <ul><li>A Stream is a general name given to flow of data. </li></ul><ul><li>Different streams are used to represent different kinds of data flow. </li></ul><ul><li>Each stream is associated with a particular class, which contains member functions and definitions for dealing with that particular kind of data flow. </li></ul>
  3. 3. The Stream Class Hierarchy ios istream get() getline() read() >> ostream put() write() << fstreambase iostream Ifstream Open() Tellg() Seekg() Ofstream Open() Tellp() Seekp() fstream NOTE : UPWARD ARROWS INDICATE THE BASE CLASS
  4. 4. DIFFERENT FILE OPERATIONS <ul><li>OPENING A FILE </li></ul><ul><li>CLOSING A FILE </li></ul><ul><li>READING FROM A FILE </li></ul><ul><li>WRITING ON A FILE </li></ul><ul><li>CHECKING FOR END OF FILE </li></ul>
  5. 5. File Mode Parameters <ul><li>PARAMETER MEANING </li></ul><ul><li>Ios::app Append to end-of file </li></ul><ul><li>Ios::ate goto end of file on opening </li></ul><ul><li>Ios::binary binary file </li></ul><ul><li>Ios::in </li></ul><ul><li>Ios::nocreate open fails if file doesn’t exist </li></ul><ul><li>Ios::noreplace open fails if file already exists </li></ul><ul><li>Ios::out </li></ul><ul><li>Ios::trunc Deletes contents if it exists </li></ul>
  6. 6. FILE POINTERS
  7. 7. FILE POINTERS <ul><li>Each file object has two integer values associated with it : </li></ul><ul><ul><li>get pointer </li></ul></ul><ul><ul><li>put pointer </li></ul></ul><ul><li>These values specify the byte number in the file where reading or writing will take place. </li></ul>
  8. 8. File pointers….. <ul><li>By default reading pointer is set at the beginning and writing pointer is set at the end (when you open file in ios::app mode) </li></ul><ul><li>There are times when you must take control of the file pointers yourself so that you can read from and write to an arbitrary location in the file. </li></ul>
  9. 9. Functions associated with file pointers : <ul><li>The seekg() and tellg() functions allow you to set and examine the get pointer. </li></ul><ul><li>The seekp() and tellp() functions allow you to set and examine the put pointer. </li></ul>
  10. 10. seekg() function : <ul><li>With one argument : </li></ul><ul><li>seekg(k) where k is absolute position from the beginning. The start of the file is byte 0 </li></ul>Begin File End k bytes ^ File pointer The seekg() function with one argument
  11. 11. seekg() function : <ul><li>With two arguments : </li></ul><ul><ul><li>the first argument represents an offset from a particular location in the file. </li></ul></ul><ul><ul><li>the second specifies the location from which the offset is measured. </li></ul></ul>Begin End ^ Offset from Begin The seekg() function with two argument
  12. 12. seekg() function : <ul><li>With two arguments : </li></ul>Begin End ^ Offset from Begin The seekg() function with two argument ^ ^ Offset from end Offset from current position

×