Hi,
I'm having a problem filling a vector with strings read as lines from a file. My vector has been declared:
vector <char*> stringVector;
and I can fill it fine with
stringVector.push_back("test");
stringVector.push_back("test1");
and so on...
However when I read from a file:
ifstream fin(filename);
fin.getline(tempString, 150);
stringVector.push_back(tempString);
The vector is not filled properly, it's length is increased but the elements do not become what tempString contains. I know tempString is getting the lines of the file because I debugged using
fin.get(tempString, 150);
cout << tempString;
I also thought about setting the first element of tempString to a null terminator after each time it's been pushed onto the vector, this has no effect.
Please can someone help, it's driving me mad!