Advertisement
qradmanq

dz 3.54 v 2

Oct 8th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int a;
  10. string line;
  11. setlocale(LC_ALL, "rus");
  12. ifstream fout("C:\\testing\\test.txt");
  13. do
  14. {
  15. if (fout >> a)
  16. cout << a << " ";
  17. else
  18. {
  19. fout.clear(); // сборс режима отказа
  20. fout.ignore(1, ' '); //инорирование символа
  21. }
  22. } while (!fout.eof()); // возращает true, если файл закончился
  23. if (a == 0)
  24. cout << "В файле нет чисел";
  25. fout.close();
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement