Dec 5, 2017 at 10:48am UTC
Hello,
I am really sorry if I have a lot of questions, my problem is that I need my output to apear as string . here is my function I need only to change the ligne where I have problem because I will need the resultat_ simulation with table appearance in my projet.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
virtual void internalTransition(const vd::Time& /*time*/ )
{
vector <Patient> myPat;
vector <Generalist> myGen;
switch (S_STATE)
{
case STATE_1:
{
Generalist::fillGeneralist(myGen);
Patient::fillPatient(myPat);
S_STATE =STATE_2;
}
break ;
case STATE_2;
{
for ( int i = 0; i < 20; i++ )
{
for ( int j = 0; j < 20; j++ )
{ double dist = Patient::distance(myPat[i].GetLat(), myPat[i].GetLong(), myGen[j].GetLat(), myGen[j].GetLong() );
cout << "The distance between patient" << i + 1 << " and doctor " << j + 1 << " is " << dist << "km " << endl;
//ligne where I have problem
resultat_simulation += myPat[i].GetLat()+"\t\t" + myPat[i].GetLong()+"t\t" + dist;
}
}
STATE_2 = IDLE;
}break ;
}
}
I have already declared resultat_simulation as string and all parameters that I want to display are double ,
Thank you
Last edited on Dec 5, 2017 at 12:49pm UTC
Dec 5, 2017 at 3:03pm UTC
I added also this function because in MinGW std::to_string() does not exist
It probably
does exist, you just have to enable C++11 mode.
add this to the compiler options:
If that doesn't work, then the compiler is really old, you might look at updating it.
I should add though that using stringstream is ok as a workaround, and may offer more flexibility over how the result is formatted.
Last edited on Dec 5, 2017 at 3:05pm UTC
Dec 6, 2017 at 4:06pm UTC
Hello,
@chervil I tried and it works thank you for your help