bhupixb

Reading a file

Apr 7th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6.  
  7. ifstream object("input.txt");
  8. /*string str;
  9. while (getline(object, str)) {
  10. cout << "o : " << str << '\n';
  11. }*/
  12. stringstream st;
  13. st << object.rdbuf();
  14. cout << st.str() << '\n';
  15. string tmp = st.str();
  16. istringstream ss(tmp);
  17.  
  18. while (ss >> tmp) {
  19. cout << tmp << '\n';
  20. }
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. }
Add Comment
Please, Sign In to add comment