I'm modifying existing code for a new project. I was instructed to remove dynamic memory allocation and use static declaration.
There is a variable arrp, earlier it was a double pointer, to which memory will be allocated using malloc and will be accessed as 2D array.
Now i have changed it as pointer to array i.e: char (*arrp)[];
The size of the 2D array to which arrp points to will be known only at runtime. My problem is if size is not declared compiler throws error('char (*)[]' : unknown size)
Please refer the following code, i did something like this
char (*arrp)[]; //This will be from different module,
//I have declared as local variable for our reference
char (*parr)[2];
char arr[3][2];
parr = &(arr[0]);
arrp = (char (*)[])&(arr[0]);
//inside loops for i, j
...
printf("%c",parr[i][j]); // This works fine
printf("%c",arrp[i][j]); // Error :'char (*)[]' : unknown size)
....
//Some code
It not possible to get the size of array when arrp is declared. Is there any way to eliminate this error?