Question

a. Write declaration and open statements to link the following external filenames to their corresponding internal object names. Use only ifstream and ofstream objects.

 External Name  Internal Object Name  Mode  coba .mem  memo  binary and output  coupons.bnd  coups  binary and append  prices. dat  priFile  binary and input \begin{array}{|l|l|l|} \hline \text { External Name } & \text { Internal Object Name } & \text { Mode } \\ \hline \text { coba .mem } & \text { memo } & \text { binary and output } \\ \hline \text { coupons.bnd } & \text { coups } & \text { binary and append } \\ \hline \text { prices. dat } & \text { priFile } & \text { binary and input } \\ \hline \end{array}

b. Redo previous Exercise, using only fstream objects. c. Write close statements for each file opened in previous Exercise.

Solutions

Verified
Answered 2 years ago
Step 1
1 of 4

(a)\textbf{(a)}

When using the ifstream\texttt{ifstream} and ofstream\texttt{ofstream} objects, the input or output mode is indicated by the object

ofstream memo;
memo.open("coba.mem");

ofstream coups;
coups.open("coupons.bnd", ios::app | ios::binary);

ifstream priFile;
priFile.open("prices.dat", ios::in | ios::binary);

Create an account to view solutions

Create an account to view solutions

More related questions

1/4

1/7