I have a string located in an array of chars, and I want to parse it and increment the pointer. So I created a func that gets a (char **) as an argument, and when I pass &str there's an error - so I declared a pointer to this array, and passed &p - and it worked.
Now I'm wondering why it didn't work with the array.
For example:
void func(char **str);
int main()
{
char str[100] = {'\0'};
char *p = str;
func(&str); // vs func(&p);
}
the error is:
test2.c:194:29: error: passing argument 1 of ‘PrintVariables’ from incompatible pointer type [-Wincompatible-pointer-types]
194 | size = PrintVariables(&line, size);
| ^~~~~
| |
| char (*)[100]
I'm trying to understand the difference between char **
and char (*)[100]
, because obviously these are different types, and I don't understand why and what is the use case for each.