The parameters for memcpy
are memcpy(void *_Dst, const void *_Src, size_t _Size)
But with the following code, I pass a constant array as parameter '_Src' and it still copy the content of the array into the destination, even though I didn't pass a const void *
.
int tab[3] = { 1, 2, 3 };
memcpy(tab, (int[3]) { 7, 8, 9 }, sizeof(int) * 3);
printf("%d %d %d \n", tab[0], tab[1], tab[2]); // Output: 7 8 9
Does the expression (int[3]) { 7, 8, 9 }
returns a pointer to the first element of the array?