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

C++, How do read in the file text? I don\'t know where to start ? success = file

ID: 3821660 • Letter: C

Question

C++, How do read in the file text? I don't know where to start ?

success = file.Open(fileName);
   if (success)
   {
       while (true)
       {
           success = file.Read(fieldVector);
           if (success)
           {
               //   COMPLETE THE ROSTER LOADING HERE.
              

           }
           else
           {
               //   COMPLETE THE END-OF-FILE HANDLING HERE.
               success = true;
               break;
           }
       }

       return(success);
   }

Explanation / Answer


#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main () {
string content;
ifstream myfile ("sample.txt");
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
cout << content << ' ';
}
myfile.close();
}

else cout << "Unable to open file";

return 0;
}

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