Feb 4, 2013 at 12:47pm UTC
I need convert a integer to string, already try the function itoa, stringstream and other, but nothing work.
string noDestino[NUMHOST];
for (int j=0; j <NUMHOST; j++)
if (matrizA[sortearAcesso][j]== 1)
{ noDestino[a]= j;
a=a+1;
EV <<"noDestino:" << noDestino[j] << "\n";
}
Feb 4, 2013 at 12:51pm UTC
I do not see where you are converting an integer to an object of type std::string. I see that you are trying to assign an object of type std::string an integer.
Feb 4, 2013 at 1:02pm UTC
sorry, I post only the function, without convert, but I try this:
string noDestino[NUMHOST];
string teste;
int a=0;
for (int j=0; j <NUMHOST; j++)
if (matrizA[sortearAcesso][j]== 1)
{ itoa(j, teste, 10);
noDestino[a]= teste;
a=a+1;
EV <<"noDestino:" << noDestino[j] << "\n";
}
Feb 4, 2013 at 1:11pm UTC
Use function std::to_string
Feb 4, 2013 at 1:42pm UTC
How to use std::to_string? Can you show me a example?
I try t use string streams, would this??? but don't works....
for (int j=0; j <NUMHOST; j++)
if (matrizA[sortearAcesso][j]== 1)
{ buffer << j ;
s1 = buffer.str();
EV <<"s1:" <<s1 << "\n";
noDestino[a]= s1;
a=a+1;
EV <<"noDestino:" << noDestino[j] << "\n";
}