导读 您好,今天小编胡舒来为大家解答以上的问题。strtol函数,strtol相信很多小伙伴还不知道,现在让我们一起来看看吧!1、// 将字符串转换成长...

您好,今天小编胡舒来为大家解答以上的问题。strtol函数,strtol相信很多小伙伴还不知道,现在让我们一起来看看吧!

1、// 将字符串转换成长整数long atol(const char* s); // 将字符串转换成长整数。

2、base为基数/进制// 如果转换成功。

3、*endptr指向s; 否则*endptr指向第一个非法字符long strtol(const char*s, char** endptr, int base);long n1 = atol("13"); // n1 = 13long n2 = atol("abc"); // n2 = 0;char* p = NULL;long n3 = strtol("123", &p, 10); // n3 = 123long n4 = strtol("123", &p, 8); // n4 = 83long n5 = strtol("123xyz", &p, 10); // n5 = 123, *p = x。

本文就为大家分享到这里,希望小伙伴们会喜欢。