dickiebird
Programmer
Hi
I'm having problems fseeking on a binary file.
I tried lseek with similar problems.
Fseek works for about 200 records then I get :
16846 Memory fault(coredump)
Lseek works for 1 record and gives same problem
Relevant code is :
long pos,ddd;
char buff[40];
FILE *fd = fopen("fileix20","rb"
while(fgets(buff,40,stdin))
{
pos = strtoul(buff,NULL,10) - 10;
printf("Trace A\n"
ddd=lseek(fd,pos,0);
printf("Trace B ddd=%d\n",ddd);
}
With fseek:
Trace A and B show 200 times
Trace B always prints a value ( = offset position )
but doesn't print after failure
With lseek
Trace A shows 2 times
Trace B has a value = -1
then doesn't show after failure
Apart from my memory fault, what is the difference between
lseek & fseek anyway. I've read the manuals, but can't appreciate any difference.
Any ideas would be welcome
TIA ;-) Dickie Bird
Honi soit qui mal y pense
I'm having problems fseeking on a binary file.
I tried lseek with similar problems.
Fseek works for about 200 records then I get :
16846 Memory fault(coredump)
Lseek works for 1 record and gives same problem
Relevant code is :
long pos,ddd;
char buff[40];
FILE *fd = fopen("fileix20","rb"
while(fgets(buff,40,stdin))
{
pos = strtoul(buff,NULL,10) - 10;
printf("Trace A\n"
ddd=lseek(fd,pos,0);
printf("Trace B ddd=%d\n",ddd);
}
With fseek:
Trace A and B show 200 times
Trace B always prints a value ( = offset position )
but doesn't print after failure
With lseek
Trace A shows 2 times
Trace B has a value = -1
then doesn't show after failure
Apart from my memory fault, what is the difference between
lseek & fseek anyway. I've read the manuals, but can't appreciate any difference.
Any ideas would be welcome
TIA ;-) Dickie Bird
Honi soit qui mal y pense