delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/12/18/19:07:14

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Date: Sat, 18 Dec 2004 19:06:44 -0500
Message-Id: <200412190006.iBJ06ike016912@envy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <boo8s01asckvrn9mb24hdl9fkjjq3bqq1g@4ax.com> (message from
Radical NetSurfer on Sat, 18 Dec 2004 12:17:45 -0500)
Subject: Re: v2.953 Additional Observations
References: <boo8s01asckvrn9mb24hdl9fkjjq3bqq1g AT 4ax DOT com>
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> Apparently we are seeing that using fread() and reading a size that
> exceeds the end_of_file, causes ZERO elements to be returned; this
> does not seem to be what most people are expecting:

Please post your test program.  Mine works fine:

#include <stdio.h>

char buf[1024];

main()
{
  int rv;
  FILE *f = fopen("afile.bin", "rb");

  rv = fread (buf, sizeof(char), 128, f);
  printf("ask 128 got %d\n", rv);

  rv = fread (buf, sizeof(char), 64, f);
  printf("ask 64 got %d\n", rv);

  rv = fread (buf, sizeof(char), 128, f);
  printf("ask 128 got %d\n", rv);

  fclose(f);
  exit(0);
}

C:\TMP> dj
ask 128 got 128
ask 64 got 64
ask 128 got 64

C:\TMP>

- Raw text -


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