How do I use use a string that has been entered by the operator to search an input file for the same string to appear? i think i use string find but not sure

string search;
getline(cin, search);

string line;
while (getline(file, line)) {
  if (line.find(search) != string::npos)
    cout<<"Found!"<<endl;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.