shithub: scc

ref: 2b05b5d52482e818baf747bc8b0619fd0d26ca02
dir: /src/libc/stdio/fwrite.c/

View raw version
#include <stdio.h>

#undef fwrite

size_t
fwrite(const void * restrict ptr, size_t size, size_t nmemb,
       FILE * restrict fp)
{
	const unsigned char *bp = ptr;
	size_t n, i;

	if (size == 0)
		return 0;

	for (n = 0; n < nmemb; n++) {
		i = size;
		do
			putc(*bp++, fp);
		while (--i);
		if (ferror(fp))
			break;
	}

	return n;
}