I'm creating a little program in order to test the vector class.
I'm using a string vector then i read a text file and i'm tring to write each word in the vector (1 word for each space).
When I try to use the push_back in order to put a string into the vector appear an error that says "There isn't a function to convert a string to a char".
If i made some english error sorry.
Thanks for the help.
I read some guide that explain how work the push_back but in all of this tutorial the use this declaration.
vector<string> v_of_string;<br/>
//allocate some memeory<br/>
v_of_string[1].pushback(string to punt in the vector);<br/>
My Code
int main() {
vector<string> str;
//allocate some memory
ifstream iFile("test.txt");
int i = 0;
if (iFile.is_open()) {
while (!iFile.eof()) {
string temp;
iFile >> temp;
str[i].push_back(temp);
cout << str[i];
i++;
}
iFile.close();
}
return 0;
}