Conversion const char* -> const unsigned short* 
Author Message
 Conversion const char* -> const unsigned short*

I have:
LPCWSTR myString;

I have a function that returns a const char*.

How can I do:
myString = MyFunc();

--
Adam Clauss



Mon, 14 Feb 2005 22:18:44 GMT  
 Conversion const char* -> const unsigned short*
Do I have to allocate memory for the LPCWSTR string first?  I'm getting a
crash in debug w/ in the functino call to mbstowcs.

--
Adam Clauss


Quote:
> mbstowcs()



> > I have:
> > LPCWSTR myString;

> > I have a function that returns a const char*.

> > How can I do:
> > myString = MyFunc();

> > --
> > Adam Clauss




Tue, 15 Feb 2005 22:56:09 GMT  
 Conversion const char* -> const unsigned short*
Yes.

However, there are helper macros that may be of some use:

W2A, A2W

Note that you need to include a header (atlbase.h?) to use these.


Quote:
> Do I have to allocate memory for the LPCWSTR string first?  I'm getting a
> crash in debug w/ in the functino call to mbstowcs.



> > mbstowcs()



> > > I have:
> > > LPCWSTR myString;

> > > I have a function that returns a const char*.

> > > How can I do:
> > > myString = MyFunc();



Tue, 22 Feb 2005 01:01:35 GMT  
 Conversion const char* -> const unsigned short*

Quote:

> However, there are helper macros that may be of some use:

> W2A, A2W

> Note that you need to include a header (atlbase.h?) to use these.

<atlconv.h>


Fri, 25 Feb 2005 21:48:37 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Help: inline char const* const& max(char const* const &a, char const* const &b)

2. const char * vs char const *

3. const char *p == char const *p ?

4. converting const char* to unsigned char[1024]

5. const char* -> char*

6. const char * -> char *

7. bytes to unsigned char, unsigned short, unsigned int, ...

8. Why not static const char * const __func__ ?

9. meaning of const char *const ?

10. C++ conversion (int to const char*) need help!!!!

11. VC++6 const char * conversion to BSTR for VB6

12. Automatic conversion of string to const char *

 

 
Powered by phpBB® Forum Software