7.Write a program that accepts any file name from the command line and copies the contents of the file to a new temporary file.

 /*J_5_P_7

Write a program that accepts any file name from the command line and

copies the contents of the file to a new temporary file.

*/

#include <iostream.h>

#include <conio.h>

#include <fstream.h>


void main(int argc[], char *argv[])

{

ifstream obj1;

ofstream obj2;

char ch;


clrscr();


obj1.open(argv[1]);

obj2.open("temp.txt");


while(obj1.eof() == 0)

{

       obj1 >> ch;

       obj2 << ch;

}

cout << "File copy...";

  obj1.close();

  obj2.close();

  getch();


}

Comments