Output is absolutely undefined behaviour.
cout <<endl<<*++p<<""<<**q<<""<<*t++;
This is compiler dependent statement because here variables q and t are pointing at same memory location . Whenever the same memory location is modified twice in a single statement not separated by sequence point the final result will be dependent on compiler implementation.
The code executed in the following manner by some compiler :
- *t++
- **q
- *++p
Hence the output can be 262
However when you execute this in other compilers execution can be done as follows
- *++p
- **q
- *t++
you can get output as 2 2 2
Well you can verify the compiler dependecy issue by executing
cout <<endl<<*++p<<""<<**q<<""<<*t++;
In different line as follows
#include<stdio.h>
#include<stdlib.h>
void main()
{
int x[]={5,2,6,9,8};
int *p,**q,*t;
p=x;
t=x+1;
q=&t;
printf("%d",*++p );
printf("%d",**q );
printf("%d",*t++ );
}
Now , output will be surely 2 2 2 .