From: Luke D. <cod...@ho...> - 2003-08-07 02:48:35
|
----- Original Message ----- From: "Zodiaq" <zo...@as...> To: <min...@li...> Sent: Thursday, August 07, 2003 9:09 AM Subject: [Mingw-users] ostringstream - what am I missing?? > Hello All MinGW users, > > there is some very strange for me going on about > std::ostringstream... in my project I wanted to use it rathen than > sticking with sprintf(stdio) or wsprintf(from windows.h or any > included from it)... but when I want to use first sooner or later my > program crashes... my program is composed of main window which using > tab control shows three different dialogs... each of them may launch > own thread to do some job for it... the problems starts when one of > them receives some info which is visualised like this: > #include <sstream> > std::ostringstream some_text;//1: > some_text.str( "" ); //2:to clear > //and then for example: > some_text << "Info: " << some_integer << std::ends; > //to set text in some control (i.e. edittext control) is use: > SendMessage( some_handle, WM_SETTEXT, 0, reinterpret_cast<LPARAM>( > some_text.str( ).data( ))); I think you need to use "some_text.str().c_str()" instead, because the string returned by data() may not have a null-terminator. Luke > after few such operation program crashes at some_text (1:)definition... I > don't know where I made a mistake, I've forgot something as I have the > same problems under VC++... I know that when I use sprintf programs > works perfectly without any problems for as long as I want... does > anyone know where I made mistake?? What am I missing? This is very > annoying for me... > > btw by using sprintf I mean: > #include <stdio.h> > char some_text[ 50 ]; //size depends on where I want to use it > sprintf( some_text, "blablabla %d", some_int ); > SendMessage( some_handle, WM_SETTEXT, 0, reinterpret_cast<LPARAM>( > some_text )); > -- > regards, Zodiaq |