Change size of 2D dynamic array in C
arrays, c, dynamic
Solution
a = (int**)realloc(a, (n + 1) * sizeof(int *));
n++;
Problem
I create a 2D dynamic array: ``` a = (int**)calloc(n-1, sizeof(int)); for(i = 0; i < (n-1); i++) a[i] = (int*)calloc(n, sizeof(int)); ``` Then I need to change its size (add new line): ``` a = (int**)realloc(a, n); a[n] = (int*)calloc(n, sizeof(int)); ``` But when i want to print my array, ``` void Print(void){ int i, j; for(i = 0; i < (n-1); i++){ for(j = 0; j < n; j++){ printf("%d\t", arr[i][j]); } printf("\n"); } } ``` i have access violation. First line is printed... What should I do?