I don't understand what the code you posted has to do with your question. They seem unrelated. One thing I'll point out is that your Borland compiler must be over 10 years old. Library headers that end with ".h" are not a part of the C++ standard. Conio.h is very much depreciated as it comes from the days of DOS, and was never a part of any standard. I suggest you get a modern compiler, they aren't hard to find and generally cost nothing.
Code:#include <iostream> #include <fstream> #include <vector> using namespace std; int main() { ifstream myFile("myfile.txt"); vector<string> lines; string line; while(getline(myFile, line)) { lines.push_back(line); } cout << lines[2] << endl; return 0; }




Reply With Quote