Program to read from a file in C++.
#include <iostream>
#include <fstream>
using namespace std;
int main(){
ifstream infile;
infile.open("rehan.txt");//rehan.txt must exist in the directory in which you've created your project.
char a[40];
while (infile){
infile.getline(a,40,'\n');
cout << a << endl;
}
infile.close();
return 0;
}
See also:
No comments:
Post a Comment