my text file is in this format
studentName Student Name One FatherName Father Name of Student One separator studentName Student name Two FatherName Father name of Student Two separator studentName Student Name three FatherName Father Name of Student three separator studentName Student name four FatherName Father name of Student four
so while writing text to v2 from v1 I dont want to write "studentName", FatherName and separator. I do not want to write these because these are my separators. I just want to write student name one, father name of student one and so on.
here is my code so far
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
using namespace std;
int main()
{
vector<string> v1;
vector<string> v2;
string line;
ifstream in("names.txt", ios::in);
while(!in.eof()) {
getline(in, line);
v1.push_back(line);
}
//cout << v1.size();
copy(v1.begin(), v1.end(), v2.begin());
int ii;
for(ii = 0; ii < v2.size(); ii++) {
cout << v2[ii];
}
system("pause");
return 0;
}
while running the above code it also displays this error
Debug assertion failed Expression: vector iterator + offset out of range
Please help how can I achieve above solution?

New Topic/Question
Reply




MultiQuote





|