vjay wrote:
>
> Check the code below guys
> void main()
> {
> char a[5] = {1,2,3,4,5};
> char *ptr;
> ptr = (char*)(&a + 1);
> printf("%d",*(ptr-1));
> }
>
> The output of the program is 5
>
> But what i expected was 1.When i replace &a with a in the expression ptr =
> (char*)(a + 1); i get output as 1.what is the difference between (&a + 1)
> and (a + 1) in the above mentioned expression.Help guys its confusing.
Consider:
What does it mean when you say "&something + 1"?
What is the value of "sizeof a"?
If there were a "typeof" operator, what would be "typeof a"?
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody |
www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net |
www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <private.php?do=newpm&u=>