Lets say I have a text file, and the text file contains the following:
hello world
Welcome to C++
How would I print line by line from my .txt file? For example, this is part of my code
while (getline(input, document))
{
if (!document.empty())
{
if (lineisthere(document)) {
cout << "The word" << // << "is there" << endl;
} else {
cout << "The word" << // << "is not there" << endl;
}
line++;
}
}
input.close(); //closes the input
I want my output to look something like this:
The word Hello Word is there
However, the word Welcome to C++ is not there
It looks like you just want to use
documentwhere you have indicated//: