Rev | Line | |
---|
[9] | 1 | /*
|
---|
| 2 | * fread.c - read a number of members into an array
|
---|
| 3 | */
|
---|
| 4 | /* $Header: /cvsup/minix/src/lib/stdio/fread.c,v 1.1.1.1 2005/04/21 14:56:35 beng Exp $ */
|
---|
| 5 |
|
---|
| 6 | #include <stdio.h>
|
---|
| 7 |
|
---|
| 8 | size_t
|
---|
| 9 | fread(void *ptr, size_t size, size_t nmemb, register FILE *stream)
|
---|
| 10 | {
|
---|
| 11 | register char *cp = ptr;
|
---|
| 12 | register int c;
|
---|
| 13 | size_t ndone = 0;
|
---|
| 14 | register size_t s;
|
---|
| 15 |
|
---|
| 16 | if (size)
|
---|
| 17 | while ( ndone < nmemb ) {
|
---|
| 18 | s = size;
|
---|
| 19 | do {
|
---|
| 20 | if ((c = getc(stream)) != EOF)
|
---|
| 21 | *cp++ = c;
|
---|
| 22 | else
|
---|
| 23 | return ndone;
|
---|
| 24 | } while (--s);
|
---|
| 25 | ndone++;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | return ndone;
|
---|
| 29 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.