Advertisement
TheDuliX_

Untitled

Oct 3rd, 2021
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. using namespace std;
  5. int main(){
  6. fstream fajl;
  7. string text;
  8. string rec;
  9. bool pronadjeno;
  10. fajl.open("fajl.txt");
  11. if (fajl.is_open()) {
  12. cout << "Unesite rec za pretragu: ";
  13. cin >> rec;
  14. while(getline(fajl, text)){
  15.  
  16. if (rec.find(text) != string::npos) {
  17. pronadjeno = true;
  18. break;
  19. } else {
  20. pronadjeno = false;
  21.  
  22.  
  23. }
  24. }
  25. }
  26. if (pronadjeno == true) {
  27. cout << "Rec je pronadjena";
  28. } else {
  29. cout << "Rec nije pronadjena";
  30. }
  31.  
  32. }
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement