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
Printable View
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);