Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CStdioFile and Seek-Method

CStdioFile and Seek-Method

Scheduled Pinned Locked Moved C / C++ / MFC
help
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tabor25
    wrote on last edited by
    #1

    Hello, i am using a CStdioFile object to read in a text-file. On some positions within the file i have to seek. I do it like this: CString line; CStdioFile file; ... /* Read a few lines */ while (condition) { file.ReadString(line) /* do something with line */ } /* Save current start-position for new line */ DWORD pos = file.GetPosition(); /* Read a few lines */ while (condition) { file.ReadString(line) /* do something with line */ } /* Go back to saved position */ file.Seek(pos,CFile::begin); Positioning the file-pointer by using the seek-method works only correct, if every line has a 0A 0D at the end. Now i have to parse a file that only has 0A at the end and the seek-method fails. It sets the file-pointer to the middle of a line and not to the beginning of the expected line. Please help! Best regards tabor25

    V 1 Reply Last reply
    0
    • T tabor25

      Hello, i am using a CStdioFile object to read in a text-file. On some positions within the file i have to seek. I do it like this: CString line; CStdioFile file; ... /* Read a few lines */ while (condition) { file.ReadString(line) /* do something with line */ } /* Save current start-position for new line */ DWORD pos = file.GetPosition(); /* Read a few lines */ while (condition) { file.ReadString(line) /* do something with line */ } /* Go back to saved position */ file.Seek(pos,CFile::begin); Positioning the file-pointer by using the seek-method works only correct, if every line has a 0A 0D at the end. Now i have to parse a file that only has 0A at the end and the seek-method fails. It sets the file-pointer to the middle of a line and not to the beginning of the expected line. Please help! Best regards tabor25

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      Do you know whether ReadString() appends or overwrite previous data in a CString object? Kuphryn

      T 1 Reply Last reply
      0
      • V valikac

        Do you know whether ReadString() appends or overwrite previous data in a CString object? Kuphryn

        T Offline
        T Offline
        tabor25
        wrote on last edited by
        #3

        Hello Kuphryn, ReadString() overwrites the previous data in the Cstring object. Best regards tabor25

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups