I'm trying to create a program that will search a given directory txt file for a certain string. Once that string is found, the program will print onto the screen the information only on that line within the txt file. My code is able to check and see if the string is inside the file, but instead of printing only the line it's contained in, it prints everything but the line I want.
while(!inF.eof()){
getline(inF, hold);
if(hold.find(crnS)){
isFound = 1;
cout << hold << endl;
}
}