+ 1
Why *(a++) is not working in main function ?
3 Answers
+ 4
In main, the "a" is not a pointer, you need to do this:-
printf ("0 = %d\n" , *a) ;
printf ("1 = %d\n" , *(a+1);
+ 3
Array notation won't advance on pre/post increment like pointer notation does.
Try this?
https://code.sololearn.com/cF918k4igw2j/?ref=app
+ 2
I'm not sure I can explain, but it probably has something to do with operator precedence, because post & pre increment operator has higher precedence over indirection (dereference) operator.
It works fine if we use an actual int* though. Just be sure to pass the pointer (not using address-of operator &) when passing the pointer to `fun` function.
Let's wait for others' opinions ...