I have this "buggy" code :
int arr[15];
memset(arr, 1, sizeof(arr));
memset
sets each byte to 1, but since int
is generally 4-bytes, it won't give the desired output. I know that each int
in the array will we initalized to 0x01010101 = 16843009
. Since I have a weak (very) understanding of hex values and memory layouts, can someone explain why it gets initialized to that hex value ? What will be the case if I have say, 4, in place of 1 ?