Is there an easy way to append an integer to a string?
I have a for loop like this:
for (int i = 0; i < text.length(); i++) {
for (int g = 0; g < word.length(); g++) {
if (text[i] == word[g]) {
kodas.append(g);
}
}
}
and I need to get the index of the array which is equal, and the index of course is an integer type. But as I do this I get an error:
invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]|
is there a way to fix this?
Use stringstream if you are working with std::strings:
#include <sstream>newStringwill be"old5"