@Lego: I am sorry I missed the "address of" operator... I wanted to type:
printf("%d", *(char *) &(0x00000002))
But even the above is incorrect since it is not possible to take address of
a literal in C/C++.
The best way is:
const int i=0x00000002;
printf("%d", *(char *) &(i));
If this print 2, then its little-endian else big-endian (there exists
mixed-endianness also, but lets leave that for now.)
--Sundeep.
On Tue, Jun 15, 2010 at 9:05 PM, Lego Haryanto <[email protected]>wrote:
>
>
> On Mon, Jun 14, 2010 at 5:13 AM, Sundeep Singh <[email protected]>wrote:
>
>> @saurav: your code will always print 2 irrespective of the system's
>> endianness!
>>
>> correct thing to do is:
>> printf("%d", *(char *) (0x00000002))
>>
>> --Sundeep.
>>
>>
>>
> ... dereferencing a very low address pointer, are you sure?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.