www.delorie.com/djgpp/bugs/show.cgi | search |
File pru.c: #include <stdio.h> #include <stdlib.h> main() { FILE *fp; char a[100]; fp=fopen("pru.c","r"); fgets(a,100,fp); printf("%d\n",ftell(fp)); } This program prints -16205 and this is a wrong file position.
That's not really a bug: just read what you find in the description of ftell()'s companion function fseek(), and think about what that implies. You will see quite easily that, for almost the same reason, fseek() *can't* work on text files. Maybe, that should be added to libc.inf's node about ftell()?
Upgrade to v2.01, where fseek and ftell work with text files as well.
webmaster | delorie software privacy |
Copyright © 2010 by DJ Delorie | Updated Jul 2010 |