Ask your own question, for FREE!
Computer Science 16 Online
OpenStudy (anonymous):

How these two statements are equivalent 1.*(s+2) 2.*(*(s+2)+1) where s is a two dimensional array.S[3][2].

OpenStudy (anonymous):

A two dimensional array is internally stored as 1-D. So you can refer to start of first row by s+1, second row by s+2. And each row will start from first element . So *(s+1) print s[1][1] , *(s+2) prints s[2][1] and also *(*(s+2)+1) will refer to s[2][1].

OpenStudy (anonymous):

As i think,these two statement are not equal,because above statement *(s+2)=s[2][0] (in case of 2D array) while below statement *(*(s+2)+1)=s[2][1] Remember,the index counting start from zero.

OpenStudy (anonymous):

When I programmed the above codes both are reffered to same location.But I can't resolve them.

OpenStudy (anonymous):

yes Md. Azam is right *(s+2) will refer to s[2][0] and *(*(s+2)+1) to s[2][1] as index starts from 0 in C.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!