函数原型: unsigned long int strtoul (const char* str, char** endptr, int base);
tr C-string containing the representation of an integral number. endptr Reference to an object of type char*, whose value is set by the function to the next character in str after the numerical value.
This parameter can also be a null pointer, in which case it is not used. base Numerical base (radix) that determines the valid characters and their interpretation.
If this is 0, the base used is determined by the format in the sequence (see strtol for details).
参数一 字符串的起始地址。
参数二 返回字符串有效数字的结尾地址。如 123456fe789 则返回数字f的地址。
参数三 转化基数。 例:将十进制转化为二进制
#include <iostream>#include <stdlib.h>using namespace std;int main(int argc ,char* argv[]){char* erjinzhi="1111";char* p;int shijinzhi=strtoul(erjinzhi,&p,2);cout<<shijinzhi;return 0;}