Thread: Does fgetpos work after reopening a file?

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    76

    Does fgetpos work after reopening a file?

    Does anybody know if i can use fgetpos then close+opening a file and use fsetpos with the value from fgetpos?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Sounds like it should work.

    Are you asking before trying it, or have you tried it and it doesn't work?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    76
    I ask it because i dont know what fgetpos returns. I get the idea it just returns the positing of the byte. But i cant be shure just by testing it a couple of times. I would really like to get some certainty about this because writing to random locations in files can give some nasty problems .

    (*i know that the position isnt returned but is stored in the 2nd param of fgetpos*)

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    If you understand what you're doing, you're not learning anything.

  5. #5
    Registered User
    Join Date
    Mar 2005
    Posts
    76
    thanks.. exactly the info i was looking for, at least i believe it is. Maybe a noob question, but at the top i see "Mac OS X / Darwin man pages". Is this info usable for devcpp (mingw)??

  6. #6
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    At the bottom of that page you should also see:
    The fgetpos(), fsetpos(), fseek(), ftell(), and rewind() functions con-
    form to ISO/IEC 9899:1990 (``ISO C90'').
    mingw uses gcc which conforms to the C90 standard, so yes it's usable.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 02:29 PM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM