I got quite confused when I came across char**, is it really necessary to cope with string?
For example:
double strtod(const char *nptr,char **endptr);
If endptr is not NULL, a pointer to the character that stopped the scan is stored at the location pointed to by endptr. —MSDN
This is quite complicated, why not just copy pointer to the character to endptr? All computations after the call can be achieved by passing the pointer’s value to endptr as I think.
Is char** really needed?
Imagine there’s a type called
my_type, and you have a function calledfoo()that needs a pointer to amy_typeso that it can modify it:Now, lets look at how
my_typeis actually defined:So it doesn’t matter if the type is already a pointer. If you want to pass a pointer to a variable of that type, you need its address. So the decomposition of:
would be:
Whenever you want a pointer to a variable of type
char *, you need achar **.