Files in C++

I am new in C++. Can anyone help me with the problem: Re-write the file copy program below with two functions one to open the infile and another one to open the outfile. One other modification to the program would be instead of reading and writing one character at a time, read one line and write one line at a time (use getline).
Sorry for my bad English!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 /**************************************************
Program by Dr. John P. Abraham 
Program copies a text file. 
for Students of 1370 
************************************************/ 
#include <iostream> 
#include <fstream> 
using namespacestd; 
int main() 
{  char infilename[30], outfilename[30]; 
   cout << "Enter file name to copy from: "; cin>>infilename; 
   cout << "Enter file name to copy to: "; cin>>outfilename; 
   ifstream infile; ofstream outfile; 
   infile.open(infilename); 
   outfile.open(outfilename); 
   char inc; 
   infile.get(inc); 
   while(!infile.eof()) 
   { 
     infile.get(inc); 
     cout <<inc; 
     outfile << inc; 
   } 
   infile.close(); 
   outfile.close(); 
   return0; 
}
Topic archived. No new replies allowed.