The internal representation of array is this:

suppose that the address starts from decimal number 10 and integer occupies
2 bytes

10- 0002 ( num 2 in hex)
12- 0003 ( num 3 in hex)
14- 0004 ( num 4 in hex)

Now p points to address 10 and is type char. (Even after type casts) p+1
will increment address by 1 byte (since it's char). p will now point to 11
(int *) will say that when de-referenced 2 bytes should be extracted. So the
2 bytes extracted are 11, 12. Numbers in these bytes are 02 and 00

10- 00*02* ( num 2 in hex)
12- *00*03 ( num 3 in hex)
14- 0004 ( num 4 in hex)

now (char *) says extract 1 byte for me. The extracted byte is 00. Hence 0
is printed

*Correct me if i am wrong.*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to