Guest User

Untitled

a guest
May 7th, 2012
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. Read floating point numbers into a dynamically allocated while increasing the size of the array while reading the file
  2. ifstream input("my-file.txt");
  3. vector<float> myValues;
  4.  
  5. for (float f; input >> f; )
  6. myValues.push_back(f);
  7.  
  8. ifstream input("my-file.txt");
  9. vector<float> myValues;
  10.  
  11. myValues.insert(myValues.begin(),
  12. istream_iterator<float>(input),
  13. istream_iterator<float>());
  14.  
  15. ifstream input("my-file.txt");
  16. vector< vector<float> > myValues;
  17.  
  18. for (string line; getline(input, line); ) {
  19. stringstream lineStream(line);
  20.  
  21. vector<float> thisLine;
  22.  
  23. thisLine.insert(thisLine.begin(),
  24. istream_iterator<float>(lineStream),
  25. istream_iterator<float>());
  26. myValues.push_back(thisLine);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment