fwrite.c - scc - simple c99 compiler
 (HTM) git clone git://git.simple-cc.org/scc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
       fwrite.c (336B)
       ---
            1 #include <stdio.h>
            2 
            3 #undef fwrite
            4 
            5 size_t
            6 fwrite(const void * restrict ptr, size_t size, size_t nmemb,
            7        FILE * restrict fp)
            8 {
            9         const unsigned char *bp = ptr;
           10         size_t n, i;
           11 
           12         if (size == 0)
           13                 return 0;
           14 
           15         for (n = 0; n < nmemb; n++) {
           16                 i = size;
           17                 do
           18                         putc(*bp++, fp);
           19                 while (--i);
           20                 if (ferror(fp))
           21                         break;
           22         }
           23 
           24         return n;
           25 }