By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 946 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

pushing data from file to a vector

P: 33

I'm reading from a file strings that I'm pushing into a vector of strings. Is there any way to reduce this to one line:

Expand|Select|Wrap|Line Numbers
  1. .
  2.                 fileInput >> temp;
  3.                 vecFileContent.push_back(temp);
provided these declarations

Expand|Select|Wrap|Line Numbers
  1. .
  2.                 std::ifstream fileInput;
  3.                 vector<string> vecFileContent;
I tried a couple of curiosities, like vecFileContent.push_back(fileInput.operator>>), without success.


Jun 15 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197

fileInput >> temp returns an ifstream& and vecFileContent.push_back() needs a string argument.
Jun 15 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.