I'm not new into programming (have a degree in software-engineering), but it has been a while PLUS new in C++ and windows forms. So very rusty... And especally in converting serveral different informations into a messagebox.
CHALLENGE:
From my UDP connection (made a simple client and a server) I can receive different types of information. Also the information has to be showed to different users and usertypes. In this case it's a messagebox.
String^ message;
String^ indication;
char buffer [100];
int nummer = 10;
int nummer2 = 20;
char Tnummer[100] = "telefoonnummer";
This is a simple example of my problem:
sprintf_s(buffer, "The half of %d is %d", 60, 60/2 );
message = gcnew String(buffer);
MessageBox::Show(message, indication);
I have tried several ways with the following:
message = "MESSAGE TEKST: ";
indication = "INDICATION";
MessageBox::Show(message, indication);
(works fine, no warnings)
message = String::Concat(message, nummer);
MessageBox::Show(message, indication);
(works fine, no warnings)
message = String::Concat("test met ander formaat, nummer 2 = ", nummer2);
MessageBox::Show(message, indication);
(works fine, no warnings)
I use sprintf as it's so much easier then converting all step by step.
But it would be great to see if their is a more simple way to have things converted in the same way by means of string converter or system converter that does the same as sprintf.
As I get warnings that sprintf is UNSAVE, and I do not want to use unsave options in my programming.
ANY IDEA how to transfer: different integers, strings, chars, into a text to deliver it to the messagebox::show as that only receives String^ input as I recall.
Or just links to different examples on this subject, as I tried several options, but it always comes to long coding and converting and doing it step by step. And just converting it by means of sprintf into a characterbuffer is sooooooo much easier ;)