Guest User

Untitled

a guest
May 21st, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8.  
  9.  
  10.  
  11. int main(){
  12.  
  13. fstream plik;
  14.  
  15. plik.open("C:\\Users\\matek\\Desktop\\plik.txt");
  16.  
  17. try{
  18. if(!plik.is_open()) {throw 2;};
  19. if(plik.bad() || !plik.good()) throw 2.0f;
  20.  
  21. }
  22. catch(int){
  23. cout<<"brak";system("pause"); }
  24. catch(float){cout<<"blad";}
  25.  
  26. string n;
  27. int a;
  28. char *tablica;
  29. while(!plik.eof())
  30. {
  31. getline( plik,n );
  32.  
  33. if(n.length() >0)
  34. {
  35. a = n.length();
  36. tablica = new char[a];
  37. strcpy (tablica, n.c_str());
  38.  
  39. for(int i = 0; i < a;i++)
  40. {
  41. cout<<tablica[i]<<endl;
  42. }
  43.  
  44. cout<<"Nastepna linia: "<<endl;
  45. }
  46. }
  47.  
  48.  
  49.  
  50. cout<<"dobrze"<<endl;
  51.  
  52. system("pause");
  53.  
  54. }
Add Comment
Please, Sign In to add comment