例如现在有一个字符串“fe”代表十六进制数0xfe,怎么样才能让int i ;得到最终的结果:i = 254 ;
解决方案 »
- IO完成端口中,传输数据数量为0问题?
- Combo Box调用ShowDropdown(true)后光标消失是什么原因?
- 完成端口资源释放疑惑
- debug无错,release出错,不知是啥原因啊
- 关于硬盘寿命的问题(1)
- copyfile 问题
- 如何使我加载的DLL访问主程序的内存?
- 如何自动关闭菜单
- VC里怎样调用外部的实用程序??比如windows的计算器,我用了system(),但是会先弹出dos窗口,还有什么方法吗?
- ★★有很多个字符串,要根据每个字符串进行具体处理,除了用if语句外,有更好的方法吗?
- 急!!图片分割提取的问题!!提供帮助的一定加高分!
- 用socket怎么写http上传下载的程序呀?
DWORD val = strtoul(a, NULL, 16);
#include <stdlib.h>
#include <stdio.h>void main( void )
{
char *string, *stopstring;
double x;
long l;
int base;
unsigned long ul;
string = "3.1415926This stopped it";
x = strtod( string, &stopstring );
printf( "string = %s\n", string );
printf(" strtod = %f\n", x );
printf(" Stopped scan at: %s\n\n", stopstring );
string = "-10110134932This stopped it";
l = strtol( string, &stopstring, 10 );
printf( "string = %s", string );
printf(" strtol = %ld", l );
printf(" Stopped scan at: %s", stopstring );
string = "10110134932";
printf( "string = %s\n", string );
/* Convert string using base 2, 4, and 8: */
for( base = 2; base <= 8; base *= 2 )
{
/* Convert the string: */
ul = strtoul( string, &stopstring, base );
printf( " strtol = %ld (base %d)\n", ul, base );
printf( " Stopped scan at: %s\n", stopstring );
}
}
Outputstring = 3.1415926This stopped it
strtod = 3.141593
Stopped scan at: This stopped itstring = -10110134932This stopped it strtol = -2147483647 Stopped scan at: This stopped itstring = 10110134932
strtol = 45 (base 2)
Stopped scan at: 34932
strtol = 4423 (base 4)
Stopped scan at: 4932
strtol = 2134108 (base 8)
Stopped scan at: 932