Answer to Question #271376 in C++ for Amit

Question #271376

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


1
Expert's answer
2021-11-25T07:05:00-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