Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

search a word in cpp file

#include <iostream>
           #include <string>
           #include <fstream>
           using namespace std;
int main()
{
               
             ifstream input;
		size_t pos;
              string line;

		input.open("t.txt");
		if(input.is_open())
		{
			while(getline(input,line))
			{
			 pos = line.find("hey");
			  if(pos!=string::npos) // string::npos is returned if string is not found
        {
            cout <<"Found!";
            break;
        }
			}
		}

system("pause");
}
Source by www.codeproject.com #
 
PREVIOUS NEXT
Tagged: #search #word #cpp #file
ADD COMMENT
Topic
Name
5+3 =