array with dynamic string

Hi

I am having a string called "Temperature" and i want to create an array which hold the value Temperature1,Temperature2,Temperature3..so on

1
2
3
4
5
6
7
string name = "Temperature";
string array[10];

for(int loop = 0;loop<=9;loop++)
{
array[loop] = "Temperature"+loop;
}


I am trying the above code but my o/p is "Temperature","Temperature"..so on till 10 but i want my o/p as "Temperature1","Temperature2"...so on.

Can any let me know some solution.
Last edited on
You do now attempt a ??? operator+ ( const char *, int )
Your code compiles, so some operator+ is used, but definitely not a string concatenating one.

See http://www.cplusplus.com/reference/string/to_string/
Last edited on
Topic archived. No new replies allowed.