Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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
}
}

void PrintLine(std::ostream & sout, std::string s); o sout: an output stream o s: a string to write to the strearm o returns: nothing This function simply prints a line to whatever output stream is given. The output stream might be cout, an output file stream, or a string stream. Sample Usage Sample Output My output string! SS: My output string! std::stringstream ss; std::ofstream fout; I/ f'ile out fout std:: string filename = "print LíneExample.txt"; GetoutputFileStream(&fout;, filename); std: string s = "My output string!" PrintLine(std::cout, s) PrintLine(ss, s); std::cout

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote