I\'m currently writing a callback function in C
:
static size_t writedata(void *ptr, size_t size, size_t nmemb, void *stream){
size_t wr
fwrite
writes to a FILE*
, i.e. a (potentially) buffered stdio
stream. It's specified by the ISO C standard. Additionally, on POSIX systems, fwrite is thread-safe to a certain degree.
write
is a lower-level API based on file descriptors, described in the POSIX standard. It doesn't know about buffering. If you want to use it on a FILE*
, then fetch its file descriptor with fileno
, but be sure to manually lock and flush the stream before attempting a write
.
Use fwrite
unless you know what you're doing.