Setting file position problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MrPickle
    New Member
    • Jul 2008
    • 100

    Setting file position problem

    First I open the file then scan through it to find out how big 2 arrays need to be then I set the position back to the begining with std::ifstream:: seekg( std::iostream:: beg ); but it doesn't seem to set the position if the last line's a new line?

    Why is this and how can I make it set the position to the beginning even if the last line's a new line?

    Here's my code:
    Code:
    150+ LOC removed - please post relevant code only
    Last edited by sicarie; Aug 26 '08, 07:21 PM. Reason: Full code removed - please post relevant section only
  • boxfish
    Recognized Expert Contributor
    • Mar 2008
    • 469

    #2
    Hi,
    I'm not sure this will help, but try opening the file with the ios::binary flag. I think there are some problems with newline characters that go away when you do that.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Why don't you read some data into a buffer and then append the buffer to a vector. By the time you've read the file to find the array size, you could have already built the array.

      I assume you are really using vectors and not primitive arrays.

      Comment

      Working...