Originally Posted by
Elysia
The whole l-value, r-value stuff is confusing, I'll give you that.
No matter, this isn't going anywhere, so let's all just think what we want and get along.
That's the spirit! Heaven forbid that you actually learn something. Hard-headed ignorance is bliss. /sarcasm
technosavvy, if you don't want to change your function (especially if you need to use it on arrays of different sizes), you can also use an intermediate array of pointers:
Code:
char buff[4][4];
char *pb[4];
for ( int i = 0; i < 4; ++i )
pb[i] = buff[i]; // use the automatic array-to-pointer conversion
fun(pb, 4, 4);
...
void fun(char **inpbuff, int row, int col) {
int i,j;
/*do some operation here on all elements of the array passed. e.g.*/
for(i = 0; i < row; i++)
for (j = 0; j <= col; j++ )
inpbuff[i][j] = 'a' + i + j;
}
Don't mind my blustering, Elysia's tip about changing the parameter type is also correct, even though the explanation was wrong. Choose what works best for you, but consider using a vector instead of an array altogether.