Simple Program for Write File Operation Using C++ Programming
To perform the write operation with in a file.
Simple Program for Write File Operation Algorithm/Steps:
- STEP 1: Start the program.
- STEP 2: Declare the variables.
- STEP 3: Read the file name.
- STEP 4: open the file to write the contents.
- STEP 5: writing the file contents up to reach a particular condition.
- STEP 6: Stop the program.
Simple Program for Write File Operation Example
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<fstream.h>
void main() {
char c, fname[10];
ofstream out;
cout << "Enter File name:";
cin>>fname;
out.open(fname);
cout << "Enter contents to store in file (Enter # at end):\n";
while ((c = getchar()) != '#') {
out << c;
}
out.close();
getch();
}
Sample Output
Enter File name: one.txt
Enter contents to store in file (enter # at end)
Master of Computer Applications - NEW#
Read More Articles
- Simple Merge Sort Program in C++
- Scope Resolution Operator In C++
- Simple Program for Virtual Functions Using C++ Programming
- Simple Class Example Program For Find Prime Number In C++
- Simple Example Program For Parameterized Constructor In C++
- Define Constructor in Outside Class Example Program In C++
- Simple Example Program For Copy Constructor In C++
- Simple Program for Function Overloading Using C++ Programming
- Simple Program for Single Inheritance Using C++ Programming
- Simple Program for Inline Function without Class Using C++ Programming
- Factorial Using Function Example Program In C++
- Simple Example Program For Constructor Overloading In C++
- Simple Example Program For Constructor In C++
- Simple Addition ( Add Two Integers ) Example Program
- Simple Example Program for Inline Function Using C++ Programming
- Simple Program for Read user Input Using cin
- Factorial Using Loop Example Program In C++
- Simple Stack Program in C++ Programming
- Simple Program for Friend Function Using C++ Programming
- Simple Program for Static Data and Member Function Using C++ Programming
- Simple Program for Unary Operator Overloading Using C++ Programming
- Simple Program for Multiple Inheritance Using C++ Programming
- Do While Loop Example Program In C++
- Simple Copy Constructor Example Program For Find Factorial In C++
- Simple Program for Function Template Using C++ Programming