Ok, I'm struggling a bit again. This time it's the concept of multi-dimensional char arrays.
A one-dimensional array works like this:
However, when I create a multi-dimensional array and try to pass it to a function in the same way, like this:Code:char str[15]; string(str); void string(char *str) { printf("%s\n", str); }
I get the following warnings:Code:void mstring(char *); char mstr[5][10]; string(mstr); void mstring(char *mstr) { // something }
I'm _beginning_ to grasp the concept of pointers, but there's still a long way to go. However, I'm not sure if a two-dimensional array is a pointer to a pointer, or a pointer with pointers to arrays?Code:warning: passing argument 1 of ‘mstring’ from incompatible pointer type (points to the line with the function call, string(mstr);) note: expected ‘char *’ but argument is of type ‘char (*)[10]’ (points to the prototype for the mstring function)



LinkBack URL
About LinkBacks




. yeah the typedef solution is sweet.