Segfault when calling fgetpos

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KiddoGuy
    New Member
    • Nov 2008
    • 17

    Segfault when calling fgetpos

    Hello, I am trying to save my position in a file to resume after running some checks that will position the file pointer at EOF.

    fpos_t *floc; /* location in file to where i want to return */
    /* in between here i search for a string */
    fgetpos(fp, floc); /* where fp is of type FILE* */

    I am sure it is segfaulting when calling fgetpos... What am I doing wrong? If the string is not found the function exits, so I am sure fp is at a valid position after the search.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    According to the reference
    The parameter position should point to an already allocated object of the type fpos_t

    Comment

    • KiddoGuy
      New Member
      • Nov 2008
      • 17

      #3
      Thanks very much. I malloc'd it and it now works. Is there a standard size to allocate?

      Comment

      Working...