Advertisement
Kolyach

Обработка (англ)

Dec 17th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     setlocale(LC_ALL, "russian");
  10.     fstream kpop2;
  11.     kpop2.open("kpop2.txt", ios::in);
  12.     string s, find;
  13.     char c;
  14.     while (!kpop2.eof()) {
  15.         kpop2.get(c);
  16.         s.push_back(c);
  17.     }
  18.     kpop2.close();
  19.     cout << "Enter word to find: ";
  20.     cin >> find;
  21.     int pos = s.find(find);
  22.     if (pos == -1)
  23.         cout << "Not found" << endl;
  24.     else
  25.         cout << "Word found at " << pos << " position" << endl;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement