Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- void wczytajZeSpacjami (char *nazwapliku,int n)
- {
- string s;
- ofstream fout (nazwapliku);
- if (!fout) cout<<"plik nie zostal otwarty"<<endl;
- else
- {
- for (int i=0;i<=n;i++)
- {
- getline(cin,s);
- cout<<"\npodaj tekst ze spacjami nr "<<i+1<<": ";
- fout<<endl<<s;
- }
- fout.close();
- cout<<endl;
- }
- }
- void wypiszSlowa (char *nazwapliku)
- {
- char s[256];
- ifstream fin(nazwapliku);
- if (!fin) cout<<"plik nie zostal otwarty"<<endl;
- else
- {
- cout<<"\nwczytane wyrazy:"<<endl;
- while (!fin.eof())
- {
- fin>>s;
- cout<<s<<" ";
- }cout<<endl;
- fin.close();
- }
- //cin.ignore();
- }
- int main() {
- int n;
- cin>>n;
- char *plik="dane.txt";
- wczytajZeSpacjami(plik, n);
- wypiszSlowa(plik);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement