# Thread: wondering why output is for a on first print is 2686780

1. ## wondering why output is for a on first print is 2686780

Code:
```#include <stdio.h>
#include <stdlib.h>
int f(int *d, int c, int b, int *a);
int main(void){
int a=1, b=3, c=2, d=4, e=5;
e = f(&a, f(&b,a,e,&c), e, &d);
printf("a =%d b=%d c=%d d=%d e=%d\n", a, b, c, d, e);
system("pause");
return 0;
}
int f(int *d, int c, int b, int *a) {

*a = *a + 1;
c = c + (*a);
b = b + c;
*d = *a + 2;
printf("a = %d, b = %d, c = %d, d = %d\n", a, b, c, d);
return *d - *a + 2;
}```
This was a test question we had on the test and i believe the real output is
a=3 b=9 c=4 d=5
a=5 b=14 c=9 d=7
a=7 b=5 c=3 d=5 e=4

I was wondering if anybody could find a reason why when i output it on my computer then i get
a = 2686780, b = 9 c = 4, d = 2686784
a = 2686776 b = 14 c = 9 d = 2686788
a = 7 b = 5 c=3 d=5 e = 4

bascially why in the function is a and d crazy... i imagine its something to do with the * and & might be messed up...just curious is all.

2. Originally Posted by dl27
bascially why in the function is a and d crazy... i imagine its something to do with the * and & might be messed up...
Yeah, in function f, a and d are pointers. Since you want to print what they point to, you should have written:
Code:
`printf("a = %d, b = %d, c = %d, d = %d\n", *a, b, c, *d);`

Popular pages Recent additions