+ 1
Give me some main concept of file handling
2 Answers
0
Here I write a commented example about reading files.
Maybe this will help you, I would not know how to explain the concept.
**********************************************
/include header files
#include <fstream>
#include <iostream>
using namespace std;
//main method declaration
int main ()
{
Ā Ā Ā char data[1000];
Ā Ā Ā Ā // open a file in read mode.
Ā Ā Ā ifstream infile;
Ā Ā Ā infile.open("file.txt");
Ā Ā Ā cout << "Reading content from the file" << endl;
Ā Ā Ā infile >> data;
Ā Ā Ā // write the data
Ā Ā Ā cout << data << endl;
Ā Ā Ā //read the data from the file and display it.
Ā Ā Ā infile >> data;
Ā Ā Ā cout << data << endl;
Ā Ā Ā // close the opened file.
Ā Ā Ā infile.close();
Ā Ā Ā return 0;
**********************************************
0
tnx