#include <iostream>
#include <fstream>
using namespace std;
int main()
{
std::string line, stringtobeSearched = "Foo8854.txt";
std::ifstream inFile("input.txt");
std::ofstream outFile("output.txt");
if(inFile)
{
while(getline(inFile, line, '\n'))
{
std::cout<<line<<std::endl;
if(line != stringtobeSearched)
{
outFile << line << "\n";
}
else
{
std::cout<<"string found "<<std::endl;
}
}
}
else
{
std::cout<<"file could not be read"<<std::endl;
}
inFile.close();
outFile.close();
return 0;
}
file123.txt
Bob56.txt'
Foo8854.txt
file113.txt
Bob56.txt'
Foo8854.txt
file223.txt
Bob96.txt'
Foo8814.txt
file123.txt
Bob56.txt'
file113.txt
Bob56.txt'
file223.txt
Bob96.txt'
Foo8814.txt