strtoul converts the initial numeric portion of a string to unsigned long. Its three parameters are the input string, an optional end-pointer, and the integer base. section 8.5
Parsing a command-line number
int main(int argc, char *argv[argc + 1]) { if (argc < 3) return EXIT_FAILURE; size_t len = strtoul(argv[1], nullptr, 0); double piv = strtod(argv[2], nullptr); /* ... */ } Here, nullptr discards the position of remaining input, while base 0 selects the apparent notation: binary with a leading 0b, hexadecimal with 0x, octal with 0, and decimal otherwise. section 17.5
Interpret the call through these rules:
- Pass an explicit base such as 2, 8, 10, or 16 when the accepted notation should be constrained. section 8.5
- Provide a non-null end-pointer when the caller must locate data remaining after the converted number; otherwise pass a null pointer. section 8.5 section 17.5
- Remember that conversion considers whitespace, an optional sign, the number, and remaining data; numeric character interpretation depends on the execution character set. section 8.5
- Wrap repeated defaults only deliberately: a variadic macro can supply nullptr for endptr and 0 for base while preserving explicit three-argument calls. section 17.5

