转自:https://vimsky.com/examples/usage/strtoul-function-in-c-c.html
1、介绍
unsigned long int strtoul(const char *str, char **end, int base);
str指向源字符串,end指向转换后的源字符串的下一个位置,如果str完全转换成功,那应该就是指向str最后的'\0'结束位置,base表示基数。
转换成功时,返回一个与str内容相对应的整数值。如果没有完成有效的转换,则返回0,并且会设置对应的errno。
例子:
// C++ program to illustrate the // strtoul() function #include <bits/stdc++.h> using namespace std; int main() { // initiaizing the string char str[256] = "90600 Geeks For Geeks"; // reference pointer char* end; long result; // finding the unsigned long // integer with base 36 result = strtoul(str, &end, 36); // printing the unsigned number cout << "The unsigned long integer is : " << result << endl; cout << "String in str is : " << end; return 0; } //输出: The unsigned long integer is : 15124320 String in str is : Geeks For Geeks
标签:char,strto,end,str,int,xxx,unsigned,学习,strtoul From: https://www.cnblogs.com/BlueBlueSea/p/17591727.html