practical 10YG
practical 10YG
Q A) Design a class FileDemo open a file in read mode and display the total
number of words and lines in the file.Program:
Code:-
#include <fstream>
#include <iostream>
int main () {
char data[100];
ofstream outfile;
outfile.open("afile.dat");
cin.getline(data, 100);
outfile.close();
ifstream infile;
infile.open("afile.dat");
// again read the data from the file and display it.
infile.close();
return 0;
}
Output:-