I have gone through many posts on SO , but still i am not able to resolve the issue .
I have to read :
text
pattern1
pattern2
from standard input , there are many text and patterns
.
Code :
string t,p1,p2;
while(getline(cin, t))
{
cin>>p1;
cin>>p2;
cout<<"text is = "<<t<<"\np1 is = "<<p1<<"\np2 is = "<<p2<<endl;
}
Input file :
hammer
ham
mer
gogoa
go
z
gogoa
g
o
Output :
text is = hammer
p1 is = ham
p2 is = mer
text is =
p1 is = gogoa
p2 is = go
text is =
p1 is = z
p2 is = gogoa
text is =
p1 is = g
p2 is = o