I'm trying to output a vector of string objects to a file. However, my code only outputs the first two elements of each string.
The piece of code below writes:
1
1
to a file. Rather then:
01-Jul-09
01-Jul-10
which is what I need.
ofstream file("dates.out");
vector<string> Test(2);
Test[0] = "01-Jul-09";
Test[1] = "01-Jul-10";
for(unsigned int i=0; i<Test.size(); i++)
file << Test[i] << endl;
file.close();
Is not clear to me what could be going wrong as I have used string objects before in similar contexts.
Any help would be welcome!