I'd like to read a text file and insert each line into an array.
How can I accomplish that?
Each line will have an .exe file name on it like this:
iexplore.exe
msimn.exe
msmsgs.exe
This is a discussion on Read each line of text file. within the C++ Programming forums, part of the General Programming Boards category; I'd like to read a text file and insert each line into an array. How can I accomplish that? Each ...
I'd like to read a text file and insert each line into an array.
How can I accomplish that?
Each line will have an .exe file name on it like this:
iexplore.exe
msimn.exe
msmsgs.exe
Read in with getline
Code:#include <string> #include <iostream> #include <fstream> #include <vector> using namespace std; .... ifstream file; .... string line; vector<string> vec; while(getline(file,string) && !line.empty()) vec.push_back(line);