0 0 votes Struct exam { int a; char *c; } st[]={4,"choice",5,"battle",6,"minute",8,"bookmark",7,"address"} main() { struct exam *p=st; printf("%s",p++->c); ++p; printf("%s",++p->c); printf("%d",p[0].a); printf("%s",++p++->c); printf("%s",++p->c); } Programming in C + – A_i_$_h 918 views answer comment Share Follow Print See all 7 Comments 7 7 Comments reply Rupendra Choudhary commented Jun 15, 2017 reply Follow flag Here p++->c means p->c and then do p++ // -> has higher priority than ++ ++p->c means ++(p->c) P is a pointer to an array of structure. printf("%s",p++->c); // Print p->c (Choice)then do p++ , now p is pointing to next element of array. ++p; // one more increment now p is pointing to 6,"minute" printf("%s",++p->c); //access p->c (minute and then do one increment in this string =>inute) printf("%d",p[0].a); // currently p is pointing to 6,"minute" so its p[0] so p[0].a =6 printf("%s",++p++->c); // one increment in string p->c and then p++ so o/p nute printf("%s",++p->c); // do one increment in string bookmark so o/p ookmark 1 1 replyShare A_i_$_h commented Jun 15, 2017 reply Follow flag Thank you :) 0 0 replyShare A_i_$_h commented Jun 15, 2017 reply Follow flag X = *p-->c++ and x = (*p-->c)++ How this expression will be evaluated? 0 0 replyShare Arunav Khare commented Jun 15, 2017 reply Follow flag For first expression, *p-->c++ As per precedence, --> has more highest precedence in the expression So first p-->c Then, among * and ++, ++ has more precedence So, (p-->c)++ and finally * So *((p-->c)++) For other expression, (*p-->c)++ Since brackets are given so among --> and *, --> has more precendence So, (p-->c) and then (*p-->c) and finally (*p-->c)++ 1 1 replyShare Rupendra Choudhary commented Jun 16, 2017 reply Follow flag Better you do it yourself. help from here http://www.difranco.net/compsci/C_Operator_Precedence_Table.htm 0 0 replyShare A_i_$_h commented Jun 16, 2017 reply Follow flag according to this table prefix has lower precedence that postfix then printf("%s",++p++->c); // one increment in string p->c and then p++ ,how this is evaluated this way here prefix is given higher priority than postfix and -> 0 0 replyShare Arunav Khare commented Jun 16, 2017 reply Follow flag I think pre and post are (and should be) compiler dependent... 0 0 replyShare Please log in or register to add a comment.