Hi, in the below given program the answer is
1. agpur
2. jabalpur
3. jabalpur
I understood the processing for the first two printf statements but for the last printf statement I could not understand the processing. Could anyone please explain.
Thanks in advance :)


void main()
	struct s1
		int i;
		struct s1 *p;

 static struct s1 a[]={{"Nagpur",1,a+1},{"Raipur",2,a+2},{"Jabalpur",3,a}};

 struct s1 *ptr=a;
 printf("%s \n",++(ptr->z));
 printf("%s \n", a[(++ptr)->i].z);


This would be:

ptr->p->i = 3;
So, --(ptr->p->i) = 2;

So, a[2].z is what is being printed. Which is, "Jabalpur".

Still i couldn't get it , Could you please elaborate this line

ptr->p->i = 3;

ptr is incremented in line number 18. So, ptr points to a + 1. So, ptr->p is a + 2.
Therefore, ptr->p->i = *(a + 2).i

Got it. Thanks! :)