strtol()函数

#include <stdlib.h>
#include <stdio.h>

int main()
{
 char a[] = "100";
 char b[] = "100";
 char c[] = "0x11";
 int x, y, z;
 x = strtol( a, NULL, 10 );
 y = strtol( b, NULL, 2 );
 z = strtol( c, NULL, 16 );

 printf( "x = %d ", x );
 printf( "y = %d ", y );
 printf( "z = %d ", z );
}

输出:x = 100

      y = 4

      z = 17

将字符串根据base转换为十进制整数

原文地址:https://www.cnblogs.com/scbxiang/p/4141356.html