Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
整数型 (*a)[2] にメモリを割り当てるにはどうすればよいですか? **a、*a など、*a[2] を使用しても問題ありませんが、これは異なって見えます。
誰か助けてくれませんか?前もって感謝します。
他のポインタ型と同じように、あなたが持っているとしましょう
int (*a)[2];
a2 の配列へのポインターint、次に割り当てます
a
int
a = malloc(number_of_rows * sizeof *a);
number_of_rows * (2 * sizeof (int))バイトのブロックを取得します。
number_of_rows * (2 * sizeof (int))
次に、それにアクセスします
a[i][j]
と。0 <= i < number_of_rows_0 <= j < 2
0 <= i < number_of_rows
0 <= j < 2