Let's say I have these parameters:
bool array_serialize(const void *src_data,
const char *dst_file,
const size_t elem_size,
const size_t elem_count);
Assume that src_data
is the array I'd like to write into dst_file
.
I can't quite figure out how to use fwrite
. I know that fwrite
requires four parameters:
ptr
− This is the pointer to the array of elements to be written.size
− This is the size in bytes of each element to be written.nmemb
− This is the number of elements, each one with a size of size bytes.stream
− This is the pointer to aFILE
object that specifies an output stream.
But the problem I run into is that *dst_file
is of const char
type. How can I convert this into the appropriate type to be able to use fwrite
?
I've tried doing
fwrite(src_data, elem_size, elem_count, dst_file);
but obviously this is incorrect.
Similar question for fread
as well.