小问题,FF0000怎么转换成整数!? CString str;str.Format("%d",fff); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 long atol( const char *string ); atol(fff);也是一样不行,还有其它的方法吗? 照着例子做,用strtod();/* STRTOD.C: This program uses strtod to convert a * string to a double-precision value; strtol to * convert a string to long integer values; and strtoul * to convert a string to unsigned long-integer values. */#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 ); }} 1、无论atol或是atoi都会对串中的字符进行基于10进制的检索,只要遇到非法字符即告转换结束,所以对“FF0000”的检索结束于第一个“F”,函数恒返回0;2、可以试一下strtol函数,int ii = strtol(fff,NULL,0x10); 谢谢lkwalk(一壶酌酒)Icic(Icic)(排名不分先后)送分! 如何将windows自带的计算器导入vc中,获取其中的自愿 error C2039: 'SetCheckStyle' : is not a member of 'CListBox' 鼠标滚轮消息 如何控制Clistctrl控件的list样式每列的行数、及每项的颜色? 如何动态添加消息映射 哪位大侠推荐一下截取包的工具 请问:如何采集显卡信息 一直搞不明白的问题。 怎样单独读取一组图标中的一特定图标,如16*16大小的,而不是默认的32*32大小的? 关于一个登陆窗口 如何判断数据库已经断开!!! 我再问关于MouseProc的问题?
也是一样不行,还有其它的方法吗?
/* STRTOD.C: This program uses strtod to convert a
* string to a double-precision value; strtol to
* convert a string to long integer values; and strtoul
* to convert a string to unsigned long-integer values.
*/#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 );
}
}
2、可以试一下strtol函数,int ii = strtol(fff,NULL,0x10);
Icic(Icic)
(排名不分先后)
送分!