How these two statements are equivalent 1.*(s+2) 2.*(*(s+2)+1) where s is a two dimensional array.S[3][2].
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].
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.
When I programmed the above codes both are reffered to same location.But I can't resolve them.
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.
Join our real-time social learning platform and learn together with your friends!