Mail Archives: djgpp/1996/01/19/10:48:34
HI !
First: excuse me for my previous message about undefined reference with math
that I posted twice.
Now I have a problem with the function fseek, that I explain with this example:
This is the code:
#include <stdio.h>
#include <stdlib.h>
void main ( void )
{
FILE *fp ;
if ( ( fp = fopen ( "test" , "rb" ) ) == NULL )
{
printf ( " Cannot open file for input. \n " ) ;
exit (1) ;
}
printf ( "%c\n" , getc(fp) ) ;
fseek ( fp , +1 , SEEK_CUR ) ;
printf ( "%c\n" , getc(fp) ) ;
}
The text input file name test is this line:
1234567890
The output is:
1
While I expected to see
1
3
That is what I see if I write
fseek ( fp , +2 , SEEK_SET ) ;
The problem remains also if I open the file in text mode; I tried to open it
in binary mode because I read in djgpp documentation that fseek doesn't work
properly with DOS in text mode (no one-to-one correspondence chars-bytes).
I am afraid the problem is pesent also in binary mode, isn't it ?
Thank you
andrea
- Raw text -