Click here to Skip to main content
16,015,351 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCleaning up from Visual Studio 6 Pin
dazinith30-May-02 9:47
dazinith30-May-02 9:47 
GeneralRe: Cleaning up from Visual Studio 6 Pin
Ed Gadziemski30-May-02 11:06
professionalEd Gadziemski30-May-02 11:06 
GeneralRe: Cleaning up from Visual Studio 6 Pin
Jonathan Craig30-May-02 11:56
Jonathan Craig30-May-02 11:56 
GeneralRe: Cleaning up from Visual Studio 6 Pin
Tomasz Sowinski30-May-02 12:59
Tomasz Sowinski30-May-02 12:59 
GeneralRe: Cleaning up from Visual Studio 6 Pin
dazinith31-May-02 3:20
dazinith31-May-02 3:20 
GeneralRe: Cleaning up from Visual Studio 6 Pin
James R. Twine31-May-02 10:53
James R. Twine31-May-02 10:53 
GeneralRe: Cleaning up from Visual Studio 6 Pin
mocotrah31-Aug-02 3:01
mocotrah31-Aug-02 3:01 
QuestionHow to use Unicode to std::ostrstream Pin
JohnnyG30-May-02 9:26
JohnnyG30-May-02 9:26 
I've just read how Windows NT/2000 OS's are native Unicode and that a performance hit will be encountered if using ANSI strings. So, the recommendation was to #include <tchar.h> and use the _TEXT macros and so on. I also want to build for Win 9x too so I took this recommendation to heart.

I started to convert a library I just converted from BC++ to VC++ and
encountered this problem:
TCHAR* TRadar::GetString(TCHAR *buff)
{
   ostrstream os(buff, 100);
   os << radarTag.GetString() << " " << maxRange << " " << scanTime;
   return buff;
}

The error is:

error C2664: '__thiscall std::ostrstream::std::ostrstream(char *,int,int)' : cannot convert parameter 1 from 'unsigned short *' to 'char *'

Obviously, ostrstream does not know what a Unicode array is. Is there a simpler way than below? Or, am I gonna have to do this to all of my objects that print msgs to a std::stream output. I thought the whole purpose of using TCHAR and the macros was so that I didn't have to put any conditional preprocessor statements in except defining _UNICODE.
TCHAR* TRadar::GetString(TCHAR *buff)
{
#ifdef _UNICODE
   USES_CONVERSION;
   ostrstream os(W2A(buff), 100);
#else
   ostrstream os(buff, 100)
#endif
   os << radarTag.GetString() << " " << maxRange << " " << scanTime;
   return buff;
}

AnswerRe: How to use Unicode to std::ostrstream Pin
Rama Krishna Vavilala30-May-02 9:35
Rama Krishna Vavilala30-May-02 9:35 
GeneralRe: How to use Unicode to std::ostrstream Pin
JohnnyG30-May-02 10:58
JohnnyG30-May-02 10:58 
GeneralRe: How to use Unicode to std::ostrstream Pin
Rama Krishna Vavilala30-May-02 11:04
Rama Krishna Vavilala30-May-02 11:04 
GeneralRe: How to use Unicode to std::ostrstream Pin
JohnnyG31-May-02 3:44
JohnnyG31-May-02 3:44 
GeneralRe: How to use Unicode to std::ostrstream Pin
Rama Krishna Vavilala31-May-02 3:43
Rama Krishna Vavilala31-May-02 3:43 
GeneralRe: How to use Unicode to std::ostrstream Pin
JohnnyG31-May-02 3:54
JohnnyG31-May-02 3:54 
GeneralCurrent time Pin
esapp42030-May-02 8:49
esapp42030-May-02 8:49 
GeneralRe: Current time Pin
Ravi Bhavnani30-May-02 9:18
professionalRavi Bhavnani30-May-02 9:18 
GeneralRe: Current time Pin
Bill Wilson30-May-02 11:56
Bill Wilson30-May-02 11:56 
Generalsetting text inside CHtmlView Pin
Big B30-May-02 8:34
Big B30-May-02 8:34 
GeneralRe: setting text inside CHtmlView Pin
S Fewings30-May-02 20:30
S Fewings30-May-02 20:30 
QuestionUser draw Combobox - MeasureItem doesn't get called!? Pin
30-May-02 6:57
suss30-May-02 6:57 
AnswerRe: User draw Combobox - MeasureItem doesn't get called!? Pin
Tomasz Sowinski30-May-02 13:01
Tomasz Sowinski30-May-02 13:01 
GeneralRe: User draw Combobox - MeasureItem doesn't get called!? Pin
30-May-02 13:51
suss30-May-02 13:51 
GeneralComponents and Controls in VC7 Pin
Le centriste30-May-02 6:42
Le centriste30-May-02 6:42 
GeneralRe: Components and Controls in VC7 Pin
Rama Krishna Vavilala30-May-02 7:23
Rama Krishna Vavilala30-May-02 7:23 
GeneralRe: Components and Controls in VC7 Pin
Mazdak30-May-02 9:20
Mazdak30-May-02 9:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.