constchar* names[5];
constchar* prefix = "Name_";
constchar* suffix = "_sur_1";
for(int i=0; i<5; i++)
{
//1. Create a std::string initially containing prefix
//2. Convert i+1 into a char* using the itoa function
//3. Append the char* determined above to the string
//4. Append the suffix to the string
//5. Set the current name to be the const char* contained in the string (using c_str)
}
Instead of using itoa in number 2, you could use stringstreams. They're easier to use (and, of course, they're not a C-style function!) http://www.cplusplus.com/forum/beginner/1057/
if you are not sure about the solution, please try it first and write here when you get a reasonable output.
Sorry, just trying to help, here :p
Although, the reason it wasn't working is due to a bone-headed, beginner mistake on my part (and also I didn't see the two outputs in the program. I thought the top was expected and the bottom was the outputted NOT that the top was the output of the first loop. My bad.) The problem was the const char*s returned from the string were going out of scope. You need to do dynamic allocation to get this to work.
Although, if your requirements permit, I would suggest switching to std::strings. They're nicer to work with because they deal with the memory management themselves.