Reading string char array into character buffer

How can i add string array into character buffer;
I want that
buff[0]=str2[0];
buff[1]=str2[1];

but it shows error
Non Portable string conversion
The code you showed is valid. So it is interesting what error did you get?
If str2 has type std::string and buff is defined as a character array then you can use standard function std::strcpy from <cstring>. For example

std::strcpy( buff, str2.c_str() );
Last edited on
closed account (4z0M4iN6)
vlad from moscow wrote:
The code you showed is valid.

This isn't true. There is only one truth. And the truth is, what the compiler says.

And char is something different to wchar, which you might get maybe - I don't know - by str2[0].

You can't convert a value of 24657 to a value in the range of 0 to 255. How would you do this?

What you could use, is:

Marshal::StringToHGlobalAnsi

Last edited on
Topic archived. No new replies allowed.