如何将CString转换成wstring

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何将CString转换成wstring相关的知识,希望对你有一定的参考价值。

参考技术A 可以用sscanf
如果是宽字符utf,请使用wtof

Example
This program shows how numbers stored as strings can be converted to numeric values using the atof function.

Copy Code
// crt_atof.c
//
// This program shows how numbers stored as
// strings can be converted to numeric
// values using the atof function.

#include <stdlib.h>
#include <stdio.h>

int main( void )

char *str = NULL;
double value = 0;

// An example of the atof function
// using leading and training spaces.
str = " 3336402735171707160320 ";
value = atof( str );
printf( "Function: atof( \"%s\" ) = %e\n", str, value );

// Another example of the atof function
// using the 'd' exponential formatting keyword.
str = "3.1412764583d210";
value = atof( str );
printf( "Function: atof( \"%s\" ) = %e\n", str, value );

// An example of the atof function
// using the 'e' exponential formatting keyword.
str = " -2309.12E-15";
value = atof( str );
printf( "Function: atof( \"%s\" ) = %e\n", str, value );



Output

Function: atof( " 3336402735171707160320 " ) = 3.336403e+021
Function: atof( "3.1412764583d210" ) = 3.141276e+210
Function: atof( " -2309.12E-15" ) = -2.309120e-012本回答被提问者和网友采纳

以上是关于如何将CString转换成wstring的主要内容,如果未能解决你的问题,请参考以下文章

如何将string转换成wstring C++

wstring如何转换成 LPCTSTR

如何将CString和:: std :: string :: std :: wstring互相转换?

mfc中,如何将CString 转换成 string

C++ MFC CString怎么转换成Double

如何将char数组转换为CString