+ 1

Give me some main concept of file handling

8th Jun 2017, 11:06 PM
shayan akhtar
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; **********************************************
10th Jun 2017, 3:48 AM
Joel Buenrostro
Joel Buenrostro - avatar
0
tnx
10th Jun 2017, 8:08 AM
shayan akhtar