Write a function that will copy the contents of file in.dat to the file out.dat. Check for successful file opening of both in.dat and out.dat. The loop that actually does the copy should terminate on end of file.

What will be an ideal response?


Note: in.get() is used because it will do both of two necessary things: First, it
will not ignore blanks. Second, it will return a 0 (false) when end of file is reached.
```
//copy files: in.dat to out.dat check for
//successful file opening,
//use EOF to terminate copy loop

#include
#include // for exit()
using namespace std;

int main()
{
ifstream in;
ofstream out;
in.open("in.dat");
if ( in.bad())
{
cout << "cannot open in.dat, aborting" << endl;
exit(1);
}
out.open("out.dat");
if (out.bad())
{
cout << "cannot open in.dat, aborting" << endl;
exit(1);
}
char ch;
while ( in.get(ch))
out << ch;
return 0;
}
```

Computer Science & Information Technology

You might also like to view...

After you have installed Apache, you need to start the ____ service.

A. primary B. main C. apache D. apache2

Computer Science & Information Technology

In the accompanying image of Microsoft PowerPoint 2016, Box A points to the _____.? ?

A. ?navigation bar B. ?menu bar C. ?review pane D. ?reference pane

Computer Science & Information Technology

Ideally, you should create rules for a minimum number of page elements.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

A transactional database is the database used to record daily transactions

Indicate whether the statement is true or false

Computer Science & Information Technology