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.
#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;
}
Comments
Leave a comment