1

In my program i have tried to increment pointer but i am not sure why that when i use *pointer++ it does nor seem to work and it returns 1 as the new value. I tried using "*pointer++" in my program like you would use a pointer as an array using *pointer=*pointer+1.
but it seems that when i use just "*pointer++" the value changes to one but when i use (*pointer)++ it works .why?

Node=(node *)malloc(num*sizeof(node));
printf("%d",Node);
Node++;
printf("%d",Node);
Mr Josh
  • 120
  • 2
  • 11

1 Answers1

4

*pointer++ dereferences the object and increases the pointer itself and after the sequence point it points (references) to the next object.

(*pointer)++ dereferences the pointer and increases (after the sequence point) only the referenced object and leaves the pointer not changed

0___________
  • 60,014
  • 4
  • 34
  • 74