CString problems from VC++ 6.0 to Visual Studio 2005
-
This is probably a known problem with an easy workaround, but I haven`t seen it yet. The problem is that I want to use code written in Visual C++ 6.0 in Visual Studio 2005. When I compile I get the following errors e.g.:
CString temp = pOrder->GetItemNr();
pOrder->GetItemNr()
returns aconst char*
the error I got is: error C2440: 'initializing' : cannot convert from 'const char *' to 'ATL::CStringT' What can I do so that this assignment works again? Anyone got any ideas? Thanks for any help, Davy -
This is probably a known problem with an easy workaround, but I haven`t seen it yet. The problem is that I want to use code written in Visual C++ 6.0 in Visual Studio 2005. When I compile I get the following errors e.g.:
CString temp = pOrder->GetItemNr();
pOrder->GetItemNr()
returns aconst char*
the error I got is: error C2440: 'initializing' : cannot convert from 'const char *' to 'ATL::CStringT' What can I do so that this assignment works again? Anyone got any ideas? Thanks for any help, DavyGDavy wrote:
CString temp = pOrder->GetItemNr();
Modify this to,
CString temp = CString(pOrder->GetItemNr());
Prasad MS MVP - VC++
-
GDavy wrote:
CString temp = pOrder->GetItemNr();
Modify this to,
CString temp = CString(pOrder->GetItemNr());
Prasad MS MVP - VC++
Isn`t there a better way? In my old code I have a lot of places where a const char* is assigned into a CString sometimes directly sometimes as a parameter in a function. It`s a lot of places to do this. :( Anyway thanks for your answer, I was affraid this might be the only solution...
-
This is probably a known problem with an easy workaround, but I haven`t seen it yet. The problem is that I want to use code written in Visual C++ 6.0 in Visual Studio 2005. When I compile I get the following errors e.g.:
CString temp = pOrder->GetItemNr();
pOrder->GetItemNr()
returns aconst char*
the error I got is: error C2440: 'initializing' : cannot convert from 'const char *' to 'ATL::CStringT' What can I do so that this assignment works again? Anyone got any ideas? Thanks for any help, DavyI certainly use this construct regularly in VS2005 and it works OK for me. What I have just checked is:
const char lpszFiles[] = "FileInfo"; CString str = lpszFiles;
essentially the same. You haven't got unicode defined have you?Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
-
I certainly use this construct regularly in VS2005 and it works OK for me. What I have just checked is:
const char lpszFiles[] = "FileInfo"; CString str = lpszFiles;
essentially the same. You haven't got unicode defined have you?Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
-
GDavy wrote:
CString temp = pOrder->GetItemNr();
Modify this to,
CString temp = CString(pOrder->GetItemNr());
Prasad MS MVP - VC++
What's the difference ? Both will call the same CString constructor so I don't see why it would work...
Cédric Moonen Software developer
Charting control [v1.1] -
What's the difference ? Both will call the same CString constructor so I don't see why it would work...
Cédric Moonen Software developer
Charting control [v1.1]That's what I thought too originally, but doing this does make it work (compiler error is gone) So I guess I`ll just have to do this for all the cases in my old code :sigh: . Just came back from easter hollidays and now this mind-numbing job of putting CString () whereever the compiler complains... I need hollidays again :^)
-
What's the difference ? Both will call the same CString constructor so I don't see why it would work...
Cédric Moonen Software developer
Charting control [v1.1]Cedric Moonen wrote:
Both will call the same CString constructor
I thought that way initially. But, some how it is converting
char*
towchar_t*
in this case.Cedric Moonen wrote:
I don't see why it would work...
And it is working.
Prasad MS MVP - VC++