2进制转换10进制数 #include <stdio.h> void main(){ char str[80] = {0,}; long iResult = 0; int i = 0; printf("输入2进制数/n"); scanf("%s",str); while(str[i]=='1'|| str[i]=='0'){ iResult <<=1; iResult +=(str[i]-'0'); i++; } printf("%d/n",iResult); }