delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/09/01/15:59:04

From: steph AT candide DOT cs DOT uchicago DOT edu (Stephen Bailey)
Subject: ftell & fgetpos bug in b18.
1 Sep 1997 15:59:04 -0700 :
Sender: mail AT cygnus DOT com
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <9709011817.AA01305.cygnus.gnu-win32@candide.cs.uchicago.edu>
Original-To: gnu-win32 AT cygnus DOT com
Original-Sender: owner-gnu-win32 AT cygnus DOT com

ftell and fgetpos report incorrect positions under some circumstances
in B18.  I am running on Windows NT 4.0 (SP3).

If you run the program included below with the /* comment me out */
line commented out, ftell erroneously reports ``5'' for the position
in the (existing, and sufficiently large) file foo.txt.  With this
line in, ftell correctly reports ``2'' as the position in the input
file.

Steph

------------------------ftelltst.c------------------------------------
#include <stdio.h>

main ()
{
  FILE *f;
  long int p;
  int c;

  f = fopen("foo.txt", "r");
  (void) ftell(f); /* comment me out */
  c = getc(f);
  c = getc(f);
  p = ftell(f);
  fprintf(stderr,"Position: %d\n", p);
  
}
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019