From e9f8235df528efd492488c248c11de87747e7a01 Mon Sep 17 00:00:00 2001 From: Rick Shi Date: Thu, 29 Jun 2017 15:18:10 +0800 Subject: [PATCH] Should be 'm' but not 'n' here --- .../exercises/ex_3.63.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/03-elementary_data_structures/3.07-compound_data_structures/exercises/ex_3.63.c b/03-elementary_data_structures/3.07-compound_data_structures/exercises/ex_3.63.c index f02b7ee..ffeb7e8 100644 --- a/03-elementary_data_structures/3.07-compound_data_structures/exercises/ex_3.63.c +++ b/03-elementary_data_structures/3.07-compound_data_structures/exercises/ex_3.63.c @@ -5,21 +5,21 @@ int ***malloc3d(int m, int n, int p) { int i, j; int ***t = malloc(m * sizeof(int **)); - - for (i = 0; i < n; i++) - { - t[i] = malloc(n * sizeof(int *)); - for (j = 0; j < n; j++) - t[i][j] = malloc(p * sizeof(int)); - } + + for (i = 0; i < m; i++) + { + t[i] = malloc(n * sizeof(int *)); + for (j = 0; j < n; j++) + t[i][j] = malloc(p * sizeof(int)); + } return t; } -int main(void) +int main(void) { int m, n, o; int ***a; - + a = malloc3d(m, n, o); return 0; }