-2

someone help me pls I do not know how to create the code for highlighting a word from a string file I will just simply put an open and close parenthesis to the word which will serve as the tool for highlighting

btw here's the code

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>

using namespace std;

void getFile(ifstream& open_file, string paragraph);
void contentFile(ifstream& open_file);

int main()
{
    ifstream fin;
    getFile(fin, "Paragraph.txt");
    contentFile(fin);

    return 0;
}

void getFile(ifstream& open_file, string paragraph)
{
    open_file.open(paragraph.c_str());
    if (open_file.fail())
    {
        cout << "Input file opening failed" << endl;
        exit(1);
    }
    else
    {
        cout << "Input file opening successful" << endl;
    }
}

void contentFile(ifstream& open_file)
{
    string line;
    while (!open_file.eof())
    {
        getline(open_file, line);
        cout << line << endl;
    }
}
Armin Montigny
  • 11,761
  • 3
  • 15
  • 37
  • 3
    It is not clear what you are asking. Notes: C++ doesn't know what a highlight is. [Why is iostream::eof inside a loop condition (i.e. `while (!stream.eof())`) considered wrong?](https://stackoverflow.com/questions/5605125/why-is-iostreameof-inside-a-loop-condition-i-e-while-stream-eof-cons) – user4581301 May 08 '22 at 06:03

0 Answers0