Please clarify, what output do you want? What is the strange output you got? What do you mean
messages, just text strings, or maybe popup message dialogues (MessageBoxEx)?
Also the sprintf function is perfectly standard C++, and there is no problem in using it still. I
think the reason your assignment didn't work was because you tried to add '+' a c-string to a float,
which isn't a valid combination in C++ (although it is valid in Java).
Try this:
string text = "alfa";
text += number;
text += " $";
or:
string text = string("alfa") + number + string(" $");
I'm not certain about the validity of the second one, but the idea is right. The string class has
operator overloading for the + symbol to allow you to add non-string types to it, but the old
c-string, which is just an array of chars doesn't allow it.
Jason.
----- Original Message -----
From: "Zodiaq" <zo...@ac...>
To: <dev...@li...>
Sent: Thursday, June 13, 2002 11:28 PM
Subject: [Dev-C++] howto construct messages in win32
Hello to all dev-cpp users,
I know it is a little OT, but I need some help... does anybody have
a good idea how to contruct properly messages in win32 environment...
question is kinda strange, so let me specify my problem:
I would like to build messages from chars, put inside some doubles
(FLOATs) and then some other chars etc... well I know that sprintf
works fine, but I want to use some newer (C++ , Win32 or std)
methodes... I tried ostrstream but behavour is veeeeery strange when I try
to write to it more than once - I get only numbers... then I tried
string and use it:
string text = "alfa" + number + " $";
but then, when sending it to controls I get a VERY strange behavour -
sending it by text.c_str( ) in controls (edit boxes) I get text from
my program, but from very strange places - like from error messages...
So finishing - does anybody know a good solution for my problem...
btw I'm using Visual C++ .NET (few houres ago I used VC 6 and I got
the same errors... and waiting for some fully functional Dev-C++ and
new mingw...) and WinXP if it helps in anything...
For now the only way for me is to write my own methods... but this
will take time, which I don't have much to spare...
--
regards, Zodiaq...
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|