"aneesh" <an********@hotmail.com> wrote:
You need:
#include <stdio.h>
int main()
{
char* p = "hello";
printf("%d",*((int*)p));
Add:
return 0;
}
char* is acutally non aligned and we r casting it to int* and
accessing the value, will there be any perfomance issue related to
alignment.
Performance issues are the least of your worries. This is undefined
behaviour for good reasons.
a) If sizeof(int) > 6 then you are accessing out of the bounds of
the array.
b) If the object when interpreted as an integer forms a trap
representation your program may crash.
c) If the alignment is wrong for an integer, your program may crash
with a 'bus error' or equivalent.
--
Simon.