posted on 2011-06-10 12:22 Hsssssss 阅读(726) 评论(1) 编辑 收藏 引用 所属分类: C++代码
int hexstr2dec(const char* str){ int result = 0; int decnum = 0; int i = 0; int length = strlen(str); do { if(str[i]<='9'&&str[i]>='0') decnum=str[i]-'0'; else if(str[i]<='f'&&str[i]>='a') decnum=str[i]-'a'+10; else if(str[i]<='F'&&str[i]>='A') decnum=str[i]-'A'+10; else{ return result; } result <<= (i << 2); result += decnum; } while (i++ < length); return result;} 回复 更多评论
Powered by: C++博客 Copyright © Hsssssss