Find us On Facebook

Thursday, April 7, 2011

File in c++

#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<process.h>
#include<string.h>

void main()
{
    fstream fin,fout;
    char ch;
    int flag = 1;
    clrscr();
    fin.open("data.txt",ios :: out | ios :: in);
    fout.open("data1.txt",ios :: out | ios :: in);
    fin.seekg(0);
    if(fin==NULL)
       cout<<"Unable to open file";
    while(fin)
    {
        fin.get(ch);
        if(ch == ' ')
        {
             flag = 0;
        }
        else
        {
            if(flag == 0)
            {
                fout.put(' ');
                cout<< ' ';
                flag = 1;
            }
            fout.put(ch);
            cout<<ch;
        }
    }
}

0 comments:

Post a Comment

Programms

C,C++,VB, PL/SQL EBOOK SEARCH ENGINE