Wednesday, 21 May 2014

files in c++



#include<iostream>
#include<conio.h>
#include<string.h>
#include<fstream>
using namespace std;
int main()
{
    ofstream out;
    out.open("temporary.txt");
    string s1,s2;
    cout<<"enter the string"<<endl;
    cin>>s1;
    cout<<"enter another string"<<endl;
    cin>>s2;
    out<<s1;
    out<<s2;
    out.close();
    ifstream in;
    in.open("temporary.txt");
    string n1;
    in>>n1;
    ofstream out1;
    out1.open("temporary1.txt");
    out1<<n1;
    out1.close();
    ifstream in1;
    in1.open("temporary1.txt");
    in1>>n1;
    cout<<n1;
    in.close();
    in1.close();
    getch();
    return 0;
}
Follow my blog with Bloglovin

No comments:

Post a Comment