F
Frederick Ding
Hi, guys,I met a problem, Please look at the problem below:
int* bit = (int*)malloc(10000*sizeof(int));
memset(bit, 1, 10000*sizeof(int));
printf("%d %d %d\n", bit[1],bit[2], bit[9999]);
Output: 16843009 16843009 16843009
Obviously I set the bit[0] to bit[9999] to 1, but it outputs are not
1's.
Why is this happen? Do I misused memset or sth else?
Any help is appreciated. Thanks!
int* bit = (int*)malloc(10000*sizeof(int));
memset(bit, 1, 10000*sizeof(int));
printf("%d %d %d\n", bit[1],bit[2], bit[9999]);
Output: 16843009 16843009 16843009
Obviously I set the bit[0] to bit[9999] to 1, but it outputs are not
1's.
Why is this happen? Do I misused memset or sth else?
Any help is appreciated. Thanks!