I have a file named read.txt E:\My_project\dictionary database\read.txt
and it looks like
1245
15
12
454564
122
....
I want to read the read.txt line by line and want to save these value into a vector and finally output the vector and write the values of vector into another txt file named write.txt which will be look same as read.txt?? How can i do this in C++???
I tried to read the value from file like this:
ifstream ifs("read.txt", ifstream::in);
But i dont understand where to keep the read.txt file.What should be the location of read.txt and write.txt???
Edited: if i use vector to save the input from the text i m getting an error:
int textLine;
vector<int> input;
ifstream ifs("C:\\Users\\Imon-Bayazid\\Desktop\\k\\read.txt", ifstream::in);
if (ifs.good()) {
while (!ifs.eof()) {
getline(ifs, textLine);
input.push_back(textLine);
}
ifs.close();
} else
cout << "ERROR: can't open file." << endl;
for(int i=0;i<input.size();i++)
cout<<input.at(i);