I have this array,
char *buffer = (char *) calloc(size, 1);
How can write it into an SD card file? I used f.write(buffer, size);
, but I got on this error:
invalid conversion from 'char*' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]
You need to cast in C++:
f.write((uint8_t *)buffer, size);
BTW, never use calloc
or malloc
on Arduino or any other low resources machine. The main problem is that the heap will fragment very quickly and eventually you will not have any memory available for allocation even if the free heap memory will be larger than the requested amount. If you need to use dynamic allocation read about memory pools