Getting a char array from a vector<int>?

Posted by Legend on Stack Overflow See other posts from Stack Overflow or by Legend
Published on 2010-03-25T20:08:44Z Indexed on 2010/03/25 20:13 UTC
Read the original article Hit count: 381

Filed under:
|
|

I am trying to pass a value from C++ to TCL. As I cannot pass pointers without the use of some complicated modules, I was thinking of converting a vector to a char array and then passing this as a null terminated string (which is relatively easy).

I have a vector as follows:

12, 32, 42, 84  

which I want to convert into something like:

"12 32 42 48"

The approach I am thinking of is to use an iterator to iterate through the vector and then convert each integer into its string representation and then add it into a char array (which is dynamically created initially by passing the size of the vector). Is this the right way or is there a function that already does this?

© Stack Overflow or respective owner

Related posts about c++

Related posts about beginner