Connecting Tech Pros Worldwide Forums | Help | Site Map

Segfault when calling fgetpos

Newbie
 
Join Date: Nov 2008
Posts: 17
#1: Nov 21 '08
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.

Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Nov 21 '08

re: Segfault when calling fgetpos


According to the reference
Quote:
The parameter position should point to an already allocated object of the type fpos_t
Newbie
 
Join Date: Nov 2008
Posts: 17
#3: Nov 21 '08

re: Segfault when calling fgetpos


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