class f2011fq1d
{
unsafe public static void Main()
{
int a = 2;
int b = 4;
int* p;
int* q;
int[] ia = { 11, 12, 13 };
p = &a;
q = &b;
Console.WriteLine(*p + a);
Console.WriteLine(*q / *p);
Console.WriteLine(*&a + *&b * 2);
*p = a + *q;
Console.WriteLine(a + *q);
fixed (int* r = ia)
{
Console.WriteLine(*r + 3);
}
}
}
I get a = 2, b = 4, therefore p = 2 and q = 4.
First output i get its 4 (2+2)
Second output i get its 2 (4/2)
This output and on i do not get, i thought that the *&a dereferences the pointer and makes it the original, but that doesnt work.
The output of this program is 4
2
10
10
14
Can someone please explain how they got it, thank you!

New Topic/Question
Reply



MultiQuote





|