This is how strtol should be declared in accordance with Β§ 7.22.1.4 of C11 (n1570):
#include <stdlib.h> long int strtol (const char *restrict nptr, char **restrict endptr, int base);
To my knowledge, the restrict keyword means that the object referenced by lvalue *nptr will only be available with it or with its value directly derived from it.
However, many programmers and even experienced ones use strtol as follows:
#include <stdlib.h> strtol (p, &p, 10);
In this case **endptr == **&p == *p == *nptr , and the behavior is undefined. Right?
source share