using C Pointer with char array
问题 int i=512; char *c = (char *)&i; c[0] =1; printf("%d",i); this displays "513", it adds 1 to i. int i=512; char *c = (char *)&i; c[1] =1; printf("%d",i); whereas this displays 256. Divides it by 2. Can someone please explain why? thanks a lot 回答1: Binary The 32-bit number 512 expressed in binary, is just: 00000000000000000000001000000000 because 2 to the power of 9 is 512. Conventionally, you read the bits from right-to-left. Here are some other decimal numbers in binary: 0001 = 1 0010 = 2