#include <stdio.h> #include <stdlib.h> int main( void ) { const char* s = "00001101"; char* pend; long dec = strtol( s, &pend, 2 ); printf( "%ld\n", dec ); // 应该输出 13 }