在EVC中如何将CString转换成int或者double类型?

situju 2006-02-18 06:52:06
CString str1 = "653";
CString str2 = "32.65892";
请问如何将上面两个变量转换成653和32.65892?
谢谢
...全文
429 8 打赏 收藏 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
luocolor 2006-03-05
  • 打赏
  • 举报
回复
xuexi
shmily1280 2006-02-22
  • 打赏
  • 举报
回复
WIN CE 的字符是UNICODE的
所以
int n = _wtoi(str1);
double d = wcstod(str2,NULL);
slyzhang 2006-02-20
  • 打赏
  • 举报
回复
Example

/* 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 );
}
}
Output

string = 3.1415926This stopped it
strtod = 3.141593
Stopped scan at: This stopped it

string = -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
slyzhang 2006-02-20
  • 打赏
  • 举报
回复
strtol, wcstolSee Also
atof
Convert strings to a long-integer value.

Routine Required Header
strtol <stdlib.h>
wcstol <stdlib.h>

long strtol( const char *nptr, char **endptr, int base );
long wcstol( const wchar_t *nptr, wchar_t **endptr, int base );
Parameters
v111v111 2006-02-20
  • 打赏
  • 举报
回复
网上搜索一下,很多地方都有
situju 2006-02-20
  • 打赏
  • 举报
回复
int n = atoi(str1 );
double d = atof(str2);
只能得到str1和str2的首位数字,下面的就得不到了
yangyzqo 2006-02-19
  • 打赏
  • 举报
回复
晕,这些问题已经有人问过了,你去查查以前的贴子看看
社会栋梁 2006-02-19
  • 打赏
  • 举报
回复
int n = atoi(str1 );
double d = atof(str2)
内容概要:本文介绍了COSO企业风险管理框架,阐述了企业风险管理的定义、目标、构成要素及其与内部控制的关系。文章指出,企业风险管理是一个由董事会、管理层及其他人员实施的,应用于战略制定并贯穿于企业之中的过程,旨在识别可能影响主体的潜在事项,管理风险以使其在该主体的风险容量之内,并为主体目标的实现提供合理保证。该框架强调了企业风险管理的八大构成要素:内部环境、目标设定、事项识别、风险评估、风险应对、控制活动、信息与沟通、监控。此外,文章还讨论了企业风险管理的局限性,如人为判断失误、成本与效益的权衡、管理层凌驾等。 适合人群:具备一定管理学基础知识,对风险管理有兴趣的学者、企业管理人员、内部审计师及外部审计师。 使用场景及目标:①帮助组织理解并应用企业风险管理框架,以提高组织的风险管理水平;②指导企业如何通过有效的风险管理来实现其战略、经营、报告和合规目标;③为企业提供一套标准化的风险管理语言,促进内外部沟通与合作。 阅读建议:读者应结合实际案例,深入理解每个构成要素的具体应用,同时关注企业风险管理的局限性,以全面把握企业风险管理的本质。此外,建议定期回顾和更新风险管理策略,以适应不断变化的内外部环境。

19,524

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 嵌入开发(WinCE)
社区管理员
  • 嵌入开发(WinCE)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧