How do you make a c++ program search for a string? -


how make c++ program search string?

i'm new programming language c++.

is there way program string of .txt file , if program found it?

first open ifstream open file check string:

#include <iostream> #include <fstream> #include <string> using namespace std;  int main () {   string line;   ifstream myfile ("example.txt");   if (myfile.is_open())   {     while ( getline (myfile,line) )     {       if(line.find("the string find") != string::npos)       {          //line found,       }     }     myfile.close();   }    else cout << "unable open file";     return 0; } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -