ack/lang/cem/libcc.ansi/stdio/fread.c

30 lines
445 B
C
Raw Normal View History

1989-05-30 13:34:25 +00:00
/*
* fread.c - read a number of members into an array
*/
/* $Header$ */
#include <stdio.h>
size_t
1989-12-18 15:04:14 +00:00
fread(void *ptr, size_t size, size_t nmemb, register FILE *stream)
1989-05-30 13:34:25 +00:00
{
1989-12-18 15:04:14 +00:00
register char *cp = ptr;
register int c;
size_t ndone = 0;
register size_t s;
1989-05-30 13:34:25 +00:00
if (size)
while ( ndone < nmemb ) {
s = size;
do {
if ((c = getc(stream)) != EOF)
1989-12-18 15:04:14 +00:00
*cp++ = c;
1989-05-30 13:34:25 +00:00
else
return ndone;
} while (--s);
ndone++;
}
return ndone;
}