fseek error

Mar 3, 2009 at 6:16am
Hi,

I am using fseek to expand a file..

suppose the current file size is 100bytes..

now i seek to 100 bytes.. and write 10 bytes of information that i want..

it is giving me a seek error. (the api description say.. one can seek outside the file's length as well)

1
2
3
4
5
6
//seek the page position
if(fseek(heapfile, (tempFreePageNum * PAGE_SIZE_IN_BYTES), SEEK_SET) != 0){
	err = SEEK_ERROR;
	goto ret;
}


how do i fix this ? (please do let me know if i have to furnish any details)

(pardon me using goto :) )

Thanks.
Mar 3, 2009 at 6:23am
please terrordrone can you explain more what you need to do in order we can help you ?
Mar 3, 2009 at 6:27am
I am getting a seek error at that part.. i do not understand why i am getting a seek error.. it sometimes works and sometimes doesnt...

heapfile is a file pointer.. opened in r+ mode
Mar 3, 2009 at 6:34am
do you include stdio.h ?
Mar 3, 2009 at 6:36am
I am getting a run time error.
Mar 3, 2009 at 6:43am
you got seek error this mean that the condition of "if" is satisfied
so now look what satisfy this condition
Last edited on Mar 3, 2009 at 6:43am
Mar 3, 2009 at 6:45am
i thin you may use seek_end and not seek_set
Mar 3, 2009 at 6:54am
will modify the logic to use seek_end and will post what happens...
Topic archived. No new replies allowed.