On Fri, May 20, 2011 at 3:19 PM, siva viknesh <sivavikne...@gmail.com> wrote:
>
> main()
> {
> int i = 257;
> int *iPtr = &i;
> printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) );
> }
> Answer:
> 1 1
>

i = 100000001

first case *((char *)iPtr) cast to char 8 bits, discard first bit
00000001  ==> 1
second *((char *)iPtr+1) cast to char 8bit address of pointer of type
char (8 bits) + 1 (next 8 bits) ==> 1


[0000 0001]               [0000 0001] = 257
*((char *)iPtr+1)        *((char *)iPtr


>
> main()
> {
> int i = 258;
> int *iPtr = &i;
> printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) );
> }
> Answer:
> 2 1
>

same as above.

>
>
> ..can anybody explain how??
> --
> Regards,
> $iva
>
> --
> 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.
>



-- 
Alin Rus

-- 
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