Thursday, 7 March 2019

CPP-EX11


Command line argument Prgram using file handling

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdlib.h>

int main(int argc,char *argv[])
{
clrscr();
int number[9]={-21,-2,-4,43,32,-1,431,4,7};
for(int i=0;i<7;i++)
{
            if(number[i]>0)
                        fout2<<number[i]<<"";
            else
                        fout1<<number[i]<<"";
}
fout1.close();
fout2.close();
ifstream fin;
char ch;
for(i=0;i<argc;i++)
{
            fin.open(argv[i]);
            cout<<"content of"<<argv[1]<<"\n";
            do
            {
                        fin.get(ch);
                        cout<<ch;

            }
            while(fin);
            cout<<"\n\n";
            fin.close();

}        getch();
//       return 0;
}