Answer to Question #255459 in C++ for JacksonCrews

Question #255459

Assignment: Functions


void printBanner() – This function should open the file “banner.txt” in the same directory as the program, and print it’s contents to the terminal. It does not depend on any other functions.


1
Expert's answer
2021-10-23T23:31:27-0400
#include<iostream>
#include<fstream>
using namespace std;


void printBanner(){

       ifstream myReadFile;
         myReadFile.open("banner.txt");
         cout<<"testing of the function call"<<endl;
         char output[100];
         if (myReadFile.is_open()) {
                cout<<"testing of banner print if fucntion"<<endl;
         while (!myReadFile.eof()) {


            myReadFile >> output;
            cout<<output;
            cout<<"Banner printed successfully"<<endl;


            }
        }
    myReadFile.close();
}
int main(){

cout<<"test"<<endl;
printBanner();

return 0;
}

Output:


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS