#include"stdio.h"
#include"math.h"
int main()
{ char s[10];
unsigned long n, htod();
gets(s);
n = htod(s);
printf("%u\n",n);
}
unsigned long htod(char *s)
{
int i,j;
long int sum;
sum=0;
i=strlen(s);
for(i=i-1,j=0;i>=0;i--,j++)
{
if(s[j]>='0'&&s[j]<='9')
sum=(s[j]-48)*pow(16,i)+sum;
else if(s[j]>='a'&&s[j]<='f')
sum=(s[j]-87)*pow(16,i)+sum;
else if(s[j]>='A'&&s[j]<='F')
sum=(s[j]-55)*pow(16,i)+sum;
}
return sum;
}
回复6楼的
E:\未命名1.cpp In function `int main()':
6 E:\未命名1.cpp too many arguments to function `long unsigned int htod()'
8 E:\未命名1.cpp at this point in file
E:\未命名1.cpp In function `long unsigned int htod(char*)':
22 E:\未命名1.cpp [Warning] converting to `long int' from `double'
在我的电脑上就会知道会这样 完全不能编译 很是恼火 不知哪位知道这是为什么