www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/25/08:15:43

From: "Christopher Nelson" <paradox AT gye DOT satnet DOT net>
To: <djgpp AT delorie DOT com>
Subject: libc bug?
Date: Wed, 24 Mar 1999 16:38:55 -0700
Message-ID: <01be764f$7b2ea120$LocalHost@thendren>
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.71.1712.3
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Reply-To: djgpp AT delorie DOT com

    i'm not sure what my version of libc is, but I downloaded it about 1
year and a half ago, and then it was the latest i could get.

    i'm writing a free archiver for game programmers using the zlib
compression library.

    part of the code requires me to create temporary files and write some
compressed information into that file.  since libc has a tmpfile() function,
is used that.  however, when i write compressed information to the file and
then retrieve it, it does not come back the same. not even the following
code works:

file  = tmpfile();
fseek(file, 0, SEEK_SET);
fwrite(compressed_buffer, 1, compressed_bytes, file);
fseek(file, 0, SEEK_SET);
fread(compressed_buffer2, 1, compressed_bytes, file);

if (memcmp(compresed_buffer, compressed_buffer2, compressed_bytes)==0)
printf("sucess"); else printf("failure");

fclose(file);

even if i'm flushing the buffer after the seek (which i shouldn't have to do
anyway, since the docs say that seek does a flush)

However, if i change the call to fopen() rather than tmpfile(), the code
works fine.

Any ideas?

-={C}=-

- Raw text -


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