resetting file pointer

This is a discussion on resetting file pointer within the C++ Programming forums, part of the General Programming Boards category; After I reach EOF, how can I change the location of the pointer reading the file? I've tried: F.seekg(ios::beg); F.seekg(0,ios::beg); ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    36

    resetting file pointer

    After I reach EOF, how can I change the location of the pointer reading the file? I've tried:
    F.seekg(ios::beg);
    F.seekg(0,ios::beg);
    F.seekg(0);

    tellg still returns -1.

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Try calling clear() before seekg.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    ... arjunajay's Avatar
    Join Date
    May 2005
    Posts
    203
    When you hit EOF some of the error flags are set to true and in order to reset those flags,
    Try calling clear() before seekg.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with file pointer in functions
    By willie in forum C Programming
    Replies: 6
    Last Post: 11-23-2008, 01:54 PM
  2. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 03:29 PM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 02:19 PM
  4. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 04:36 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21