Lets do a trick, read it backwards "char * * endPtr":
"EndPtr" are a "pointer" to a "pointer" of type "char".
A pointer is a 32bit value in the memory (on i386). This memory holds a value thats an address of some other storage area.
[4BytesAddress] -> [4BytesAddress] -> ["SomeString"]
The only thing you realy can pass to a function in C are values, so.. to give the function a chance to return something more then its return _value_ we have to send in a value, that means something both to us and to the function. The value we sendin is an memory address of an storage area we know about. The function stores its second return argument in this memory area. After the function returns we can look in this area, in this case it will contain an address to the start of the "NonDigitPart" of the String we sent in.
This is how it looks like before we sent **endPtr into the function.
[4bytesAddress]->[NULL]
This is how it looks like after we called strtol()
[4bytesAddress]->[4bytesAddress]->["ABC"]
I used an extra variable to make it totaly clear whats going on.
Normaly you just call the function like:
myNumber = strtol(myNumStr, &pEndOfString, 10);
Code:
#include <string.h>
#include <stdlib.h>
int main() {
char *myNumStrMix = "123ABC";
char *pEndOfDigits = NULL;
char **ppEndOfDigits;
int myNumber;
ppEndOfDigits = &pEndOfDigits;
myNumber = strtol(myNumStrMix, ppEndOfDigits, 10);
printf("From '%s' I got '%d' and this '%s'\n",
myNumStrMix, myNumber, pEndOfDigits);
return EXIT_SUCCESS;
}
Hope this helped.