首页 > 编程知识 正文

strtok函数,strtoul函数什么意思

时间:2023-05-05 00:16:43 阅读:262033 作者:1922

此函数功能为:把输入的字符串转换成数字。
函数原型: 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;}


版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。