For example t[i]
is *(t+i)
How it will be for t[i][j]
?
In my opinion *(*(t+i)+j)
but not sure.
Yes, what you have is correct. t[i][j]
may be written as (t[i])[j]
, so you may then apply the "1D" rule recursively.
You have to know how the data is stored in memory, as you want to operate on pointers. For 2-dimensional arrays there is no significant difference - the "rows" just tells how many "cells" the app should skip.
Let's assume for a while, that t
is an integer, so when you have an array, which looks like this:
|3|4|5|
|6|5|4|
it will look, in fact like
|3|4|5|6|5|4|
as stored in memory. The array means that the program has to "skip" after 3rd value in array x[3][2]
, then t[i][j]
would look like *(*(t+i)+j)
Yes, you're right. t[i][j]
is equivalent to *(*(t + i) + j)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.