8 8 votes #include <stdio.h> void f(char**); int main() { char *argv[] = { "ab", "cd", "ef", "gh", "ij", "kl" }; f(argv); return 0; } void f(char **p) { char *t; t = (p += sizeof(int))[-1]; printf("%s\n", t); } (a) ab (b) cd (c) ef (d) gh In GATE Exam, if not specified What should be size of integer? Programming in C programming-in-c output pointers interview + – Desert_Warrior 1.9k views answer comment Share Follow Print See 1 comment 1 1 comment reply Rishabh Gupta 2 commented Sep 11, 2017 reply Follow flag Size of int depends on the machine, and hence the answer can vary on different machines. 0 0 replyShare Please log in or register to add a comment.
Best answer 5 5 votes Answer will be D) gh Here p will initially point to the "ab", p += sizeof(int) This will translate into p = p + 4; // Consider size of int is 4 Now p will point "ij". (p)[-1]; will translate into *(p - 1), then it will return the address of "gh", //Why address of "gh", because p is double pointer, hence single pointer will return the address its element. Then t will have the address of "gh". Hence "gh" will be printed. rude answered May 17, 2016 • selected May 17, 2016 by Desert_Warrior rude comment Share Follow See all 3 Comments 3 3 Comments reply Desert_Warrior commented May 17, 2016 reply Follow flag So size of integer = 4 byte // if not specified. 0 0 replyShare rude commented May 17, 2016 reply Follow flag If not specified then we will take 4 only. But if specifically say that its 2 byte then only consider that. 1 1 replyShare Arjun commented Sep 11, 2017 reply Follow flag For the practical purpose, we should take sizeof int as 4. But in GATE it will always be specified or else they will give marks for both 2 and 4. 0 0 replyShare Please log in or register to add a comment.