0 0 votes include <stdio.h> int main() { char *c[]={"abhi","abhishek","abhisheksing"}; printf("%s",(*(*(c+2)+7))); return 0; } What is the output? Programming in C + – Spider1896 1.1k views answer comment Share Follow Print See all 7 Comments 7 7 Comments reply anjali007 commented Aug 22, 2018 i edited by anjali007 Aug 22, 2018 reply Follow flag We are given an array of pointers which points to the 3 strings. abhi abhishek abhisheksing Initially c points to the first cell. *(c+2) means that c now points to the 3rd cell. The pointer is currently at 'a'. a b h i s h e k s i n g 0 1 2 3 4 5 6 7 8 9 10 11 Now when we add 7 to it it points to k and ksing gets printed. The output is :ksing. 0 0 replyShare Spider1896 commented Aug 22, 2018 reply Follow flag No the output is Segmentation fault 0 0 replyShare MiNiPanda commented Aug 22, 2018 reply Follow flag Yup right.. that extra * in " (*(*(c+2)+7)) " won't give the result as (*(*(c+2)+7)) means 'k'. But using %s requires an address value and that is returned by (*(c+2)+7). (*(*(c+2)+7)) returns a character and not an address. So printf("%c", (*(*(c+2)+7)) ) will work and not printf("%s", (*(*(c+2)+7)) ). 1 1 replyShare anjali007 commented Aug 22, 2018 reply Follow flag yup there is an extra *.. If %c is there the ans will be only k. 0 0 replyShare Rishav Kumar Singh commented Aug 22, 2018 reply Follow flag Yes minipanda correct. 0 0 replyShare Mayankprakash commented Aug 22, 2018 reply Follow flag @minipanda 1.Pleasesuggest if it should print with '%s' then what should be the correct statement for output ''ksing". 2.%c--> requires value at an address and it prints only charachar. %s-->requires starting address or any address of an array and it prints tills null character 3. (*(C+2)+7)---->&A[2][7]. Let A be an array. Please suggest on above three points whether my understanding is correct? 0 0 replyShare MiNiPanda commented Aug 22, 2018 reply Follow flag 1. printf("%s", (*(c+2)+7) ); this will print ksing 2. Yes..both are right 3. Yes true..both printf("%s", (*(c+2)+7) ); AND printf("%s", &c[2][7] ); will give "ksing" and they mean the same. 0 0 replyShare Please log in or register to add a comment.