Answer to Question #272499 in C++ for kgbbb

Question #272499

Information like name and roll number and read that file and print the content on screen. Write a program using which you will able to create file student info in which you need to provide necessary.


1
Expert's answer
2021-11-28T05:26:05-0500
#include <iostream>
#include <fstream>
using namespace std;
int main(){
    char filename[50];
    cout<<"Enter filename to read: ";
    cin>>filename;
    ifstream file(filename, ios::in);
    if(file){
        while(!file.eof()){
            char c = file.get();
            cout<<c;
        }
        file.close();
    }
    else{
        cout<<"error opening file\n";
    }
    return 0;
}

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