Advertisement
DeagleM

Untitled

Feb 4th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. void wczytajZeSpacjami (char *nazwapliku,int n)
  5. {
  6. string s;
  7. ofstream fout (nazwapliku);
  8. if (!fout) cout<<"plik nie zostal otwarty"<<endl;
  9. else
  10. {
  11. for (int i=0;i<=n;i++)
  12. {
  13. getline(cin,s);
  14. cout<<"\npodaj tekst ze spacjami nr "<<i+1<<": ";
  15. fout<<endl<<s;
  16. }
  17. fout.close();
  18. cout<<endl;
  19. }
  20. }
  21. void wypiszSlowa (char *nazwapliku)
  22. {
  23. char s[256];
  24. ifstream fin(nazwapliku);
  25. if (!fin) cout<<"plik nie zostal otwarty"<<endl;
  26. else
  27. {
  28. cout<<"\nwczytane wyrazy:"<<endl;
  29. while (!fin.eof())
  30. {
  31. fin>>s;
  32. cout<<s<<" ";
  33. }cout<<endl;
  34. fin.close();
  35. }
  36. //cin.ignore();
  37. }
  38.  
  39. int main() {
  40. int n;
  41. cin>>n;
  42. char *plik="dane.txt";
  43. wczytajZeSpacjami(plik, n);
  44. wypiszSlowa(plik);
  45. return 0;
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement