Write a function that takes and returns an istream&. The function should read the stream until it hits end-of-file. The function should print what it reads to the standard output. Reset the stream so that it is valid before returning the stream.
Test your function by calling it, passing cin as an argument.
What causes the following while to terminate?
while (cin >> i) /* ... */
Write a function to open a file for input and read its contents into a vector of strings, storing each line as a separate element in the vector.
Rewrite the previous program to store each word in a separate element.
Rewrite the bookstore program from § 7.1.1 (p. 256) to read its transac- tions from a file. Pass the name of the file as an argument to main (§ 6.2.5, p. 218).
Revise the bookstore program from the previous section to write its out- put to a file. Pass the name of that file as a second argument to main.
Revise the program from the previous exercise to append its output to its given file. Run the program on the same output file at least twice to ensure that the data are preserved.
Use the function you wrote for the first exercise in § 8.1.2 (p. 314) to print the contents of an istringstream object.
Write a program to store each line from a file in a vector. Now use an istringstream to read each element from the vector a word at a time.
The program in this section defined its istringstream object inside the outer while loop. What changes would you need to make if record were defined outside that loop? Rewrite the program, moving the definition of record outside the while, and see whether you thought of all the changes that are needed.
Why didn’t we use in-class initializers in PersonInfo?
Rewrite the phone number program from this section to read from a named file rather than from cin.
Why did we declare entry and nums as const auto &?