if I input a binary file to array buf, why do I have to input it by (void*) ?? and why do I have to write it by (void*)?? please observe this code and please explain this code to me. (I just copy this code from my book)
int main(void) {
FILE * src = fopen("a.png", "rb");
FILE * des = fopen("b.png", "wb");
char buf[20];
int readCnt;
if (src == NULL || des == NULL) {
puts("File open failed");
return -1;
}
while (1) {
readCnt = fread((void*)buf, 1, sizeof(buf), src);
if (readCnt < sizeof(buf)) {
if (feof(src) != 0) {
fwrite((void*)buf, 1, readCnt, des);
puts("File copy complete");
break;
}
else
puts("File copy Failed");
break;
}
fwrite((void*)buf, 1, sizeof(buf), des);
}
fclose(src);
fclose(des);
return 0;
}