MFC in Visual C++ 2010:
To print something in a Rich Edit Box, i use
m_rich.Insert(m_rich.GetLength(), L"Hello World");
If I want to print an integer which is variable, (i used to do this in VC++ 6.0)
1 2 3 4
|
int a=5;
char str[3];
itoa(a, str, 10);
m_rich.Insert(m_rich.GetLength(), str);
|
and it used to work.
In VC++ 2010, I get this error:-
'int ATL::CStringT<BaseType,StringTraits>::Insert(int,wchar_t)' : cannot convert parameter 2 from 'char [3]' to 'wchar_t'
Please help. Is there any alternative to the itoa conversion, which I have to do repeatedly.
Also tell me about the error and how can I get rid of it?
Last edited on
The Insert function is expecting a wide string - you are providing a normal ascii char string.
As you are on windows - look up the
itow functionand see if that helps - (You may need to make the
str array a bit bigger than 3 though.
EDIT:
Looking further , the error says:
int ATL::CStringT<BaseType,StringTraits>::Insert(int,wchar_t) |
, so that function seems to be expecting just a single wchar_t value.
Last edited on
Thank you. I'am giving it a try.
Well trying the CString method gave me the error:--
error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *'
but I figured it out. guestgulkan was correct that itow should work, but actually the syntax would be _itow() not itow(). now it works. thanks.
You may have bigger problems. Why are some of your controls Unicode and others not?