In C++, the strtol() function converts a C-style string (char*)

In C++, the strtol() function converts a C-style string (char*) to a long integer. It is defined in the header and supports different number bases (e.g., decimal, hexadecimal, octal). Unlike atoi(), strtol() provides error handling using an endptr parameter. Syntax: cpp Copy Edit long strtol(const char* str, char** endptr, int base); str: Input C-style string. endptr: Pointer to the first invalid character (can be NULL). base: Number base (e.g., 10 for decimal, 16 for hex).