c++ - How to read text file into deque -



c++ - How to read text file into deque -

i trying build deque of strings (in c++) txt file putting new entry in deque each line in file. below effort @ function - know while loop beingness executed proper number of times, after calling function queue empty. i'm sure i'm missing little (very new c++ syntax , workings...), , help appreciated.

void read_file(string file_name, deque<string> str_queue) { ifstream filestr; filestr.open(file_name); if (!filestr.is_open()){ perror ("error opening file."); } else { while (filestr) { string s; getline(filestr,s); str_queue.push_back(s); } } }

you passing queue value, not reference. seek this:

void read_file(const string &file_name, deque<string> &str_queue) {

c++

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -