Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- unsigned ilosc_slow(string wpis_slowo, ifstream& hamlet)
- {
- unsigned i=0;
- string slowa;
- while(hamlet >> slowa)
- {
- if (wpis_slowo == slowa)
- {
- i++;
- }
- }
- hamlet.close();
- return i;
- }
- int main()
- {
- string wpis_slowo;
- cout << "Podaj szukane slowo: " << endl;
- cin >> wpis_slowo;
- ifstream plik;
- plik.open("hamlet.txt");
- if(plik.good())
- {
- cout << ilosc_slow(wpis_slowo, plik) << endl;
- plik.close();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement