how do i insert <char>
arrays into <char*>
vectors something like this:
std::vector<char> ch;
ch.push_back('H');
ch.push_back('e');
ch.push_back('l');
ch.push_back('l');
ch.push_back('o');
std::vector<char*> vec;
vec.push_back(ch);
but it gives error saying : push_back() cannot convert parameter 1 from....
So is there a way to load ch[]
values into vec[0]
and still use one of my function which searches for the contents in the vector for example:
vecf[]
contains a file contents in it, i can search through the vecf[0]vecf[1]...
for a similar content like searching a text "Hello"
from "Hi, Hello..."
?
As I was told my Question was unclear, So here is the clearer version: It is Possible to do like this:
char string[]="Hello World";
std::vector<char*> vec;
vec.push_back(string);
cout<<vec[0];
then if a string is of type std::vector like this:
std::vector<char> string;
std::vector<char*> vec;
how would i do like this?
vec.push_back(string);
or something like this to get the contents of string into vec, and ch and vec is not in the real project, i used the term ch and vec for just an example to how to do like this, in my project theres a char vector variable ID which is something like this ID="ID2" but in vector, the ID's values is loaded from a file, there is another tag which contains refering ID which i will compare with the ID[0]/ID[1] until one matches if one matched i will get its position on array, then theres another vector variable(int) which contains all the nodes position of array in the file, i will use like this SPos[ArrayPos] to get the position of the node in the file, hope this was clear enough...