int to char conversion

Hi, I need to store the value of an int variable as an element in a string. i.e.

1
2
3
4
string S = "abcde";
int count;
count = 15; //i.e count gets assigned some value during the course of the program
S[3] = count; //<= problem! I want to store count as an i'th element of the string but the problem is that count is an int and I don't know its value so can't use '15' 


I want S to become "abc15e". How could I do this?

For example it can be done the following way

1
2
3
4
5
6
7
string S = "abcde";
int count = 15;
char tmp[3];


sprintf( tmp, "%2.2d", count );
s.insert( 3, tmp );
I believe he wants to replace one character with the number, not insert.

This is a duplicate thread: http://www.cplusplus.com/forum/general/63495/

Please do not post a question more than once.
Sorry for the duplicate posting. I got it working based on the inputs on my other post. Thanks
for the replies guys.
Topic archived. No new replies allowed.