Hello! I have been trying to come up with a code that overwrites a row of a dynamic 2D array/matrix for quite some time, and when I thought I managed to do it turns out it works for `number of rows>number of columns`type of a matrix only. I am fairly new to this and can not seem to find an error .
Code:
printf("Enter a number of a row you wish to delete: ");
scanf_s("%d", &k);
if (k >= 0 && k < vr) { //vr is number or rows
for (i = 0; i < kol; i++) { //kol -nmbr of columns
unsigned int *tmp;
for (j = k + 1; j < vr; j++) a[j - 1][i] = a[j][i];
tmp = realloc(a[i], (vr - 1) * sizeof(unsigned int));
if (tmp == NULL) {
printf("ERROR\n");
exit(1);
}
else a[i] = tmp;
}
vr--;