Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2007

Tip: Looking for answers? Try searching our database.

error C2440: '<function-style-cast>' : cannot convert from 'const TCHAR *' to 'std::string'

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bit Byte - 06 Mar 2007 09:50 GMT
Are there any macros for converting between these two string types ?
David Wilkinson - 06 Mar 2007 12:14 GMT
> Are there any macros for converting between these two string types ?

Bit Byte:

Please don't put the whole question in the title.

Very likely you do not really want to make this conversion. You must
understand that in non-Unicode build TCHAR is CHAR (char) while in
Unicode build it is WCHAR (wchar_t). A good way to use the standard
library in Windows programs is

typedef std::basic_string<TCHAR> tstring;
TCHAR str[] = _T("Testing");
tstring s = str;

This will compile in either Unicode or non-Unicode build.

If your program really uses both 8-bit and 16-bit strings you should
look at W2A family of macros, or WideCharToMultiByte().

David Wilkinson

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.