Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5. int main()
  6. {
  7. const int n = 5;
  8. int tablica[n];
  9. int tmp = 0;
  10. ifstream liczby("dane.txt");
  11.  
  12. if (!liczby)
  13. {
  14. cout << "Nie mozna otworzyc pliku";
  15. getchar();
  16. return 1;
  17. }
  18.  
  19. while (!liczby.eof())
  20. liczby >> tablica[tmp++];
  21.  
  22. liczby.close();
  23.  
  24. for (int i=0; i<tmp; i++)
  25. cout << "Liczba: " << tablica[i] << endl;
  26.  
  27. getchar();
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement