Question: 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?

Answer: 
**Yes**.

You can, for example:

* use the `itoa` function that converts integers into strings
* make your `kodas` an `ostringstream` and "write" into it as you would to `cout`: `kodas << g`
itoa(), its the into to alpha function, should help you out. sprintf or vsprintf works too if you want to