Consider the following code:
1: #include <stdio.h>
2: int poin(int p[4]){
3: printf("%u\n", p[0]);
4: printf("%u\n", p[1]);
5: printf("%u\n", p[2]);
6: printf("%u\n", p[3]);
7:
8: }
9: int main(){
10: int *p[4],a=1,b=2,c=3,d=4;
11:
12: p[1]=&b;
13: p[2]=&c;
14: p[3]=&d;
15: p[0]=&a;
16: poin(*p);
17: return 0;
18:}
it shows this output:
1
2686716
2686712
2686708
Process returned 0 (0x0) execution time : 0.078 s
Press any key to continue.
let's modify the program in line 14 & 15, look at the modified code:
1: #include <stdio.h>
2: int poin(int p[4]){
3: printf("%u\n", p[0]);
4: printf("%u\n", p[1]);
5: printf("%u\n", p[2]);
6: printf("%u\n", p[3]);
7:
8:}
9: int main(){
10: int *p[4],a=1,b=2,c=3,d=4;
11:
12: p[1]=&b;
13: p[2]=&c;
14: p[3]=&a;
15: p[0]=&d;
16: poin(*p);
17: return 0;
18: }
it shows the following output:
4
3
2
1
Process returned 0 (0x0) execution time : 0.062 s
Press any key to continue.
please explain me why and how these outputs occured i am very confused and not able to understand the programs