Thread: resetting file pointer

  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, 02:29 PM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  4. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM