Hello, i'd like to make a program which reads input until end of file on standard input and when i press ctrl-d (or i'm not sure how to end it) it writes out the lines which contain a string.
so if i start with :
./a.out cond
First line
Second line
Third line
it should write out:
Second line
and if i just do ./a.out it should write out all lines.
What i could do so far:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
char Char;
while (!cin.eof())
{
cin.get(Char);
str += Char;
}
cout << str;
return 0;
}