Stay Tuned!

Subscribe to our newsletter to get our newest articles instantly!

C++ Programming

C++ Program to Write and Read of User Input File

Write and Read of User Input File

C++ Program to Write and Reading of User Input File

Source Code

#include<iostream>
#include<fstream>
#include<conio.h>
using namespace std;
int main()
{
    char buffer[100],name[10], address[10];
    int maxlength=100;
    ofstream outf(“test.txt”);
    {
        cout<<“\nEnter the name : “;
        cin>>name;
        outf<<name<<endl;
        cout<<“\nEnter the address : “;
        cin>>address;
        outf<<address<<endl;
    }
        outf.close();
        ifstream fin(“test.txt”);
    {
        fin>>name>>address;
        cout<<“\nThe name is : “<<name<<endl;
        cout<<“\nThe address is : “<<address<<endl;
    }
        fin.close();
        getch();

}

Output

reading and writing files

Avatar

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.

You may also like

program to find leap year
C++ Programming

C++ Program to Find Leap Year by Using Function

  • March 3, 2016
Write a program to find if the inputted year is a leap year or not by using the concept of