You can't just use 1 index on the string because you don't know how long the number will be. There are a few ways to do this but here is 1 example. to_string is C++11 but you can look up other functions if you are stuck on C++03.
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string sexo = "sexozin_000";
for(int i = 1; i <= 31; i++)
{
string S = to_string(i);
// go back 1 or 2 from the end depending on how long the number is
sexo.replace(sexo.end() - S.length(), sexo.end(), S);
cout << sexo << endl;
}
return 0;
}
to_string is C++11 but you can look up other functions if you are stuck on C++03.
Either get Code Blocks using C++11 (I don't use it, but there is tons of info online) or you will have to use an older method to get int to string, like stringstream. http://www.cplusplus.com/articles/D9j2Nwbp/