vector<char> to char*
Hi there -
Does anyone know how of an algorithm to convert a vector to a char*?
Thanks all
Emagen
yes
char *string=new char[v.size()];
for(int i=0;i < v.size();i++)
. string=v;<br><br><br><br><br>Mike </i>
char *string=new char[v.size()];
for(int i=0;i < v.size();i++)
. string=v;<br><br><br><br><br>Mike </i>
"Unintentional death of one civilian by the US is a tragedy; intentional slaughter of a million by Saddam - a statistic." - Unknown
That doesn''t seem to work because it can''t convert a char to char*.
I need to append char to a char*, so I need to concatenate char to a char*.
Any ideas anyone?
thanks
Emagen
I need to append char to a char*, so I need to concatenate char to a char*.
Any ideas anyone?
thanks
Emagen
First, I question the wisdom of using a vector. You seem to be wanting to have an array of characters, and you could do so with std::string.
As for the answer, you can try the copy algorithm
vector V(5);
char strArray[5];
copy(V.begin(), V.end(), strArray);
where the first parameter is source begin, followed by source end, and then strArray.
Please elaborate more as I do not really get what you need
As for the answer, you can try the copy algorithm
vector V(5);
char strArray[5];
copy(V.begin(), V.end(), strArray);
where the first parameter is source begin, followed by source end, and then strArray.
Please elaborate more as I do not really get what you need
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement