I've got the following (seemingly innocent) code:
void singleLeftPadZero(char**);
int main () {
char foo[10] = "0";
singleLeftPadZero(foo); // <-- causes warning
singleLeftPadZero(&foo); // <-- same exact warning, but different "note"
}
The warning I get from gcc is:
warning: passing argument 1 of ‘singleLeftZeroPad’ from incompatible pointer type
And the note for the first case is:
note: expected ‘char **’ but argument is of type ‘char *’
I understood this to mean that I needed to pass a pointer to a pointer, but I was just passing a pointer. Hence, I added the "&" to my argument, which resulted in the same warning but this note:
note: expected ‘char **’ but argument is of type ‘char (*)[10]’
What I did which looks like it fixed it was to create an extra variable:
char* fooPntr = foo;
And then to pass the address of that as the function argument:
singleLeftPadZero(&fooPntr);
But I'm not sure why this works!