*/
# include & ltstring.h & gt
# include & ltstdio.h & gt
# include & ltmath.h & gt
int? convert(char *);
int? Major (invalid)
{
Charles? *? buf? =? " 10 1 10 1 10";
int? res? =? 0;
res? =? convert(buf); ? //Function call
printf(" % s-& gt; %d\n ",buf,? RES);
}
//Binary string is converted to decimal.
int? Transform (char? *? buf)
{
int? Me? =? 0;
int? Ryan. =? 8; //Are you sure it's 8 digits? Otherwise, find the length.
int? res? =? 0;
For (me; ? Me? & lt? len? i++){
What if? (? ! (buf[i]=='0 '? ||? buf[i]==' 1 ')? ){
Printf ("Invalid? Buffer! \ n ");
Return? 256; ? //is not a directly returned 0 1 string.
}
res? +=? (buf[i]-'0')*pow(2,len-I- 1); ? //Calculate the decimal value corresponding to the string and power ().
}
Return? res
I don't quite understand what you mean. I wonder if you want decimals. In this way, the decimal corresponding value can be obtained.