Hello everyone,
I don't know if I'm confused with itoa,excuse me for this if so, but what I'm trying to do is:
I have an array of characters, say

char example[7]

I assigned the first 4 characters by


Then I'm trying to fill the next char with an integer using itoa:


where i is an incremental integer variable in a for loop.
the rest of the char array is constant.
Thank you for your replies.

This is an ideal situation which which to use stringstreams. Are you locked into using the characters array?

Also, itoa is non-standard so it's not guaranteed to be available on all compilers.

Hello jonsca,
Well, I could switch to a string,doesn't matter at all,if only I knew how to use stringstreams :) :(

It's relatively easy:

#include <sstream>
int numbervariable = 10; //or double, etc. or use your loop counter
std::stringstream ss;
ss<<"Firstpart"<<numbervariable<<"Secondpart"; //use it just like any other stream

std::cout<<ss.str()<<" is the string portion";
This question has already been answered. Start a new discussion instead.