Hi,
I'm trying to make a program that search strings in a file and output them (or others).
My problem is, how to output a file line !?
Here is my code...
string str;
string str2 = "hate";
int i; ifstream file ("file.txt");
for (int index=1; index<=10; index++)
{
getline (file, str);
i = str.find(str2);
cout << "Line " << index << ": ";
if(i != string::npos)
// print a line... How ??
else
// print a line... How ??
}
cin.get();
file.close();
I hope you understand and you have the answer... ;)