Write a C++ Program to Enter or Insert Data into File using File Handling. Here’s simple Program to Enter or Insert Data into File using File Handling in C++ Programming Language.
Below is the source code for C++ Program to Enter or Insert Data into File using File Handling which is successfully compiled and run on Windows System to produce desired output as shown below :
SOURCE CODE : :
/* C++ Program to Enter or Insert Data into File using File Handling */
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ofstream fout;
char fname[100];
char rec[100];
cout<<"Enter file name :: ";
cin>>fname;
fout.open(fname, ios::out);
cout<<"\nEnter any word to insert :: ";
cin>>rec;
fout<<rec;
cout<<"\nData inserted successfully..!!\n";
fout.close();
return 0;
}
OUTPUT : :
/* C++ Program to Enter or Insert Data into File using File Handling */
Enter file name :: C:\\Users\\acer\\Documents\\file4.txt
Enter any word to insert :: CodezClub
Data inserted successfully..!!
Process returned 0
Above is the source code for C++ Program to Enter or Insert Data into Files using File Handling which is successfully compiled and run on Windows System.The Output of the program is shown above .
Below is the source code for C++ Program to Enter or Insert Data into File using File Handling which is successfully compiled and run on Windows System to produce desired output as shown below :
SOURCE CODE : :
OUTPUT : :
Above is the source code for C++ Program to Enter or Insert Data into Files using File Handling which is successfully compiled and run on Windows System.The Output of the program is shown above .
need an explanation for this answer? contact us directly to get an explanation for this answer