File Handling in Cpp [Read & Write]
This is a program which will perform the File Handling operations in Cpp program. In this a txt file, data.txt is created in which the input is stored and then read and displayed.
Screenshots [Demo]
The Code
Got problems, you can comment it !
Screenshots [Demo]
The Terminal window in which the data is entered and then fetched
The file data.txt, generated by the program !
The Code
#include<iostream> #include<fstream> using namespace std; int main() { fstream fp; char st[50]; fp.open("data.txt",ios::out|ios::binary); for (int i=0;i<4;i++) { cout<<"Enter THe String: "; gets(st); fp<<st<<endl; } fp.close(); fp.open("data.txt"); cout<<"Displaying the File: "; while (!fp.eof()) { fp>>st; cout<<st<<" "; } fp.close(); return 0; }
Got problems, you can comment it !
Comments
Post a Comment