I\'m having trouble with my code for these functions this is how they should tur
ID: 3764435 • Letter: I
Question
I'm having trouble with my code for these functions this is how they should turn out
Here is what I have
void PrintLine(std::ostream & sout, std::string s)
{
sout << s << endl;//prints function that is being called
}
void PrintNew(std::istream & fin, std::ostream & fout)
{
string pnew;//create a string variable
getline(fin, pnew);//get the lines
if (pnew.find("new") != string::npos)//look for the word in the file "new" and print it out
{
fout << pnew<<" ";//print out the string
}
}
Explanation / Answer
void PrintLine(std::ostream & sout, std::string s) //it is function PrintLine with soutand s as argument
{
sout << s << endl;//prints function that is being called
}
it will print the s in file
void PrintNew(std::istream & fin, std::ostream & fout) //it is function with argument fin and fout
{
string pnew;//create a string variable
getline(fin, pnew);//get the lines
if (pnew.find("new") != string::npos)//look for the word in the file "new" and print it out
{
fout << pnew<<" ";//print out the string
}
}
this function will getline form file and print in output file
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.