1989-05-30 13:34:25 +00:00
|
|
|
/*
|
|
|
|
* fwrite.c - write a number of array elements on a file
|
|
|
|
*/
|
1994-06-24 14:02:31 +00:00
|
|
|
/* $Id$ */
|
1989-05-30 13:34:25 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
size_t
|
1989-12-18 15:04:14 +00:00
|
|
|
fwrite(const void *ptr, size_t size, size_t nmemb,
|
1989-05-30 13:34:25 +00:00
|
|
|
register FILE *stream)
|
|
|
|
{
|
1989-12-18 15:04:14 +00:00
|
|
|
register const unsigned char *cp = ptr;
|
|
|
|
register size_t s;
|
|
|
|
size_t ndone = 0;
|
1989-05-30 13:34:25 +00:00
|
|
|
|
|
|
|
if (size)
|
|
|
|
while ( ndone < nmemb ) {
|
|
|
|
s = size;
|
|
|
|
do {
|
1989-12-18 15:04:14 +00:00
|
|
|
if (putc((int)*cp, stream)
|
1989-05-30 13:34:25 +00:00
|
|
|
== EOF)
|
1989-06-26 10:37:05 +00:00
|
|
|
return ndone;
|
1989-12-18 15:04:14 +00:00
|
|
|
cp++;
|
1989-05-30 13:34:25 +00:00
|
|
|
}
|
|
|
|
while (--s);
|
|
|
|
ndone++;
|
|
|
|
}
|
1989-06-26 10:37:05 +00:00
|
|
|
return ndone;
|
1989-05-30 13:34:25 +00:00
|
|
|
}
|