0 votes 0 votes #include <stdio.h> int main() { int a[][3] = {1, 2, 3, 4, 5, 6}; int (*ptr)[3] = a; printf("%d %d ", (*ptr)[1], (*ptr)[2]); ++ptr; printf("%d %d\n", (*ptr)[1], (*ptr)[2]); return 0; } (a) 2 3 5 6 (b) 2 3 4 5 (c) 4 5 0 0 (d) none of the above Programming in C programming pointers array-of-pointers array + – vishalmessi asked Dec 11, 2016 vishalmessi 4.1k views answer comment Share Follow See all 9 Comments See all 9 9 Comments reply santhoshdevulapally commented Dec 11, 2016 reply Follow Share ans A? 1 votes 1 votes vishalmessi commented Dec 11, 2016 reply Follow Share Explanation? 0 votes 0 votes santhoshdevulapally commented Dec 11, 2016 i edited by santhoshdevulapally Dec 12, 2016 reply Follow Share int (*ptr)[3] // ptr is a poinetr it stores 3 integer values. int (*ptr)[3]=a; // it stores address of a. (*ptr)[1] array of first element and (*ptr[2]) array of 2nd element.those are 2,3 (++ptr) it is increased .it access 2nd dimensional array again (*ptr[1]) and (*ptr[2]) elements are 5,6 http://stackoverflow.com/questions/13910749/difference-between-ptr10-and-ptr10 1 votes 1 votes vishalmessi commented Dec 12, 2016 reply Follow Share int a[][3] = {1, 2, 3, 4, 5, 6}; int (*ptr)[3] = a; Can u explain the structure for this 2 lines 0 votes 0 votes santhoshdevulapally commented Dec 12, 2016 reply Follow Share 2)ptr is a pointer to an array of storing 3 integer values. ptr contains address of a.suppose address of a=1000 then 0 votes 0 votes santhoshdevulapally commented Dec 12, 2016 reply Follow Share it is giving result as 2,3,5,6 @vishal 0 votes 0 votes pC commented Dec 12, 2016 reply Follow Share @santhosh convert it as answer . Perhaps Many of your comments should have to be converted to answers :) 1 votes 1 votes vishalmessi commented Dec 12, 2016 reply Follow Share Does the above structure for the 2D array is correct? . Because i was unable to visualise the 2D array structure with rows not mentioned. 0 votes 0 votes santhoshdevulapally commented Dec 12, 2016 reply Follow Share two 2-d arrays a[0] and a[1] in which a[0]---a[0][0] ,a[0][1],a[0[2] elements are 1,2,3 same as a[1]--a[1][0],a[1][1],a[1][2] elements are 4,5,6 0 votes 0 votes Please log in or register to add a comment.
Best answer 2 votes 2 votes int *ptr[10]; This is an array of 10 int* pointers int (*ptr)[10]; This is a pointer to an array of 10 int *(*a+1) (*a)[1] are two diffferent representation of a[0][1] $int (*ptr)[3] $ // is nothing but ptr[][] $int (*ptr)[3]=a;$ // it stores address of a . $(*ptr)[1] $first element // nothing but a[0][1] which print 2 $(*ptr[2]) $ 2nd element. // // nothing but a[0][2] which print 3 $(++ptr)$ it is increased .it access 2nd dimensional array $(*ptr)[1] $ first element // nothing but a[1][1] which print 5 $(*ptr[2])$ 2nd element. // // nothing but a[1][2] which print 6 Output is $2,3,5,6$ http://stackoverflow.com/questions/13910749/difference-between-ptr10-and-ptr10 santhoshdevulapally answered Dec 12, 2016 • edited Dec 12, 2016 by pC santhoshdevulapally comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes Ans should be 2& 3.....5&6 ...just u need to know (*PTR)[s] can be written as *(*PTR +s)...u will able to solve problem... Anup dogrial answered Jan 7, 2020 Anup dogrial comment Share Follow See all 0 reply Please log in or register to add a comment.