|
十进制转换为十六进制- char *Hex="0123456789ABCDEF";
- char s[50],t[50];
- char* PrintHex(int a)
- {
- if(!a) return 0;
- PrintHex(a/16);
- sprintf(s,"%c",Hex[a%16]);
- strcat(t,s);
- return t;
- }
复制代码 十六进制转换为十进制- #include "stdafx.h"
- #include <iostream.h>
- #include <string.h>
- #include<windows.h>
- #include<shlwapi.h>
- #pragma comment(lib, "shlwapi.lib")
- int main(int argc, char* argv[])
- {
- int d;
- StrToIntEx( "0xFF",STIF_SUPPORT_HEX,&d);
- cout<<d<<endl;
- return 0;
- }
复制代码 |
|