Wednesday, 27 June 2012

c++ program that read from file and write into file.

#include<iostream>
#include<fstream>
using namespace std;
    int main()
    {
        ofstream myfile("t1.txt");
        char c[100];
        int a;
        cout<<"enter your number :";
        cin>>a;
        cout<<endl<<"enter your First Name:";
        cin.getline(c,100);



       myfile<<a<<endl<<c;
        myfile.close();

        ifstream myfile1("t1.txt");
        char d[100];
        int b;
        myfile1>>b>>d;
        cout<<endl<<"your number is:"<<b<<endl;
        cout<<"your First Name:"<<d;
        myfile1.close();
        return 0;
    }

No comments:

Post a Comment