Hi everyone,
Somewhere in my need i need to create strings like ( x,y,z ) with 0<x,y,z<N.
I was trying to use 3 for loops but it didn't work.
That's what i wrote:
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
for(int k=0;k<N;k++){
string t="( ";
t+=i;
t+=",";
t+=j;
t+=",";
t+=k;
t+=" )";
}
}
}
I know the reason is that i,j,k are integers and it's not possible to add integers to a string.
So i tried to convert integers into char and then add them to the string.
by writing:
for(i=0;i<N;i++){
for(int j=0;j<N;j++){
for(int k=0;k<N;k++){
string t="( ";
char* newi,newj,newk;
newi=itoa (i);
newk=itoa (k);
newj=itoa (j);
t+=newi;
t+=",";
t+=newj;
t+=",";
t+=newk;
t+=" )";
}
}
}
But that gives me this error:
error: 'itoa' was not declared in this scope
Can anybody tell me how i can do that?