I am currently in high school and I am also learning c++ (noobie).
I was interested in this thread because, I have never tried coding a function that could search a string in an input file and output the results into an output file. This is my first attempt.

This piece of code may look difficult because of its size...but its actually very simple and logic.

[CODE]
void IOSearchString()
{
string SearchString, InputFilePath, OutputFilePath, InputFileLine;

cout << "Welcome!" << endl
     << "Please enter a string you wish to find:" << endl;
cin >> SearchString;

cout << endl << "Please enter the input file's path and name" << endl
     << "(e.g c://InputFilePath//InputFileName.txt)" << endl;
cin >> InputFilePath;

ifstream InputFile(InputFilePath);
if(!InputFile.is_open() || InputFile.bad())
{
    cout << endl << "Error! Failed to open: " + InputFilePath << endl;
    system("Pause");
    exit(1);
}

cout << endl << "Please enter the output file's path and name:" << endl;
cin >> OutputFilePath;

ofstream OutputFile(OutputFilePath);
if(!OutputFile.is_open() || OutputFile.bad())
{
    cout << endl << "Error! Failed to create/find: " + OutputFilePath << endl;
    system("Pause");
    exit(1);
}

if(InputFile.good() && OutputFile.good())
{
    int CountFound = 0;
    cout << endl << "Searching for: " + SearchString << endl;
    for(int LineCount = 1; getline(InputFile, InputFileLine); ++LineCount)
    {
        for(int i = 0; i != InputFileLine.length(); ++i)
        {
            if(InputFileLine.substr(i, SearchString.length()) == SearchString)
            {
                OutputFile << "Line " << LineCount << ":" << InputFileLine << endl;
                i = InputFileLine.length() - InputFileLine.substr(i, SearchString.length()).length();
                ++CountFound;
            }
        }
    }
    cout << endl << "Searching completed!" << endl;

    if(CountFound <= ...