convert integer to string, nothing work

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";
}
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.
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";
}
Use function std::to_string
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";
}
> How to use std::to_string? Can you show me a example?
> I try t use string streams,

Example for both:
http://liveworkspace.org/code/4bCVs7$1


thanks, work!!!!!!!!!!!
Topic archived. No new replies allowed.