>So I need to know how such a function works internally.
It works the wrong way for what you're trying to do. Consider a naive implementation:
Code:
#include <cstdio>
using namespace std;
size_t jsw_fwrite ( const void *buf, size_t size, size_t count, FILE *stream )
{
if ( size == 0 )
return 0;
const unsigned char *p = static_cast<const unsigned char *> ( buf );
size_t n = 0;
for ( ; n < count; n++ ) {
for ( size_t i = 0; i < size; i++ )
fputc ( *p++, stream );
if ( ferror ( stream ) )
break;
}
return n;
}
No amount of operator overloading will make that work for a non-POD type.