Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main(){
- fstream fajl;
- string text;
- string rec;
- bool pronadjeno;
- fajl.open("fajl.txt");
- if (fajl.is_open()) {
- cout << "Unesite rec za pretragu: ";
- cin >> rec;
- while(getline(fajl, text)){
- if (rec.find(text) != string::npos) {
- pronadjeno = true;
- break;
- } else {
- pronadjeno = false;
- }
- }
- }
- if (pronadjeno == true) {
- cout << "Rec je pronadjena";
- } else {
- cout << "Rec nije pronadjena";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement