Mail Archives: djgpp/1998/04/02/11:43:09
I do not usually read the list, so I do not know whether the problem
has already been reported. If it has, I apologize for the duplication.
tmpfile() apparently creates a text file. I do not have the ANSI
Standard, but, according to K&R 2nd ed., the mode should be "wb+".
This program:
#include <stdio.h>
main ()
{
FILE *f ;
char record [1000] ;
int n ;
for (n=0;n<1000;n++)
record [n] = 'a' ;
/* record [500] = 26 ; */
f = tmpfile() ;
fwrite (record, 1, 1000, f) ;
fflush (f) ;
rewind (f) ;
n = fread (record, 1, 1000, f) ;
printf ("%d\n", n) ;
}
when compiled and linked with DJGPP 2.01, prints 1000. If the instruction
is uncommented, it prints 500.
The problem is easily bypassed by using tmpnam() and remove().
--
Gianfranco Boggio
Milano (Italy)
- Raw text -