Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- int main() {
- std::string slowo, temps;
- std::cout << "Wpisz szukane slowo: ";
- std::cin >> slowo;
- auto licznik{ 0 };
- std::ifstream hamlet{ "hamlet.txt" };
- if (hamlet.fail()) {
- std::cout << "BLAD! Plik nie zostal znaleziony!\n";
- return 0;
- }
- while (hamlet >> temps) {
- if (temps == slowo) {
- ++licznik;
- }
- }
- hamlet.close();
- std::cout << "Slowo zostalo znalezione " << licznik << " razy.\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement