0
#include<stdio.h> 
int main()
{
char a[] = { 'A', 'B', 'C', 'D' };
char* ppp = &a[0];
*ppp++;
printf("%c %c ", *++ppp, --*ppp);
return 0;
}

My expected output was C B. But Output is C A

  • You have undefined behaviour! Clang says this: **warning : unsequenced modification and access to 'ppp'** (for your `printf` line). See [here](https://stackoverflow.com/q/33743254/10871073). – Adrian Mole Apr 13 '20 at 11:20

1 Answers1

0

Use parenthesis in those cases so we understand what you want to do. Do you increase the pointer ?

 ppp++;

Do you increase the value inside ?

(*ppp)++;
adrien bedel
  • 116
  • 8