#include <stdio.h>
int bin_dec(char *p);
char * pbin = "00000101";
int main(void)
{
printf("bin: %s is dec: %d\n", pbin, bin_dec(pbin));
return 0;
}
int bin_dec(char *p)
{
int dec=0;
while(*p != '\0'){
printf("%c\n",*p);
dec = ( dec<<1 ) + *p++ - '0' ;
}
return dec;
}
将二进制字符串转化为十进制
最新推荐文章于 2023-09-04 22:15:42 发布