In the following code, elements of the const
array are cleared by the memset
function.
#include <stdio.h>
#include <string.h>
int main() {
const int a[3] = {1, 2, 3};
memset(a, 0, sizeof(a));
printf("%d %d %d\n",a[0],a[1],a[2]);
return 0;
}
Is it legal to use memset
on const
array?