More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions

I l @ ve RuBoard

Difficulty: 2

What's the best way to dynamically use different stream sources and targets, including the standard console streams and files?

  1. What are the types of std::cin and std::cout ?

  2. Write an ECHO program that simply echoes its input and that can be invoked equivalently in the two following ways:

    ECHO <infile >outfile ECHO infile outfile

    In most popular command-line environments, the first command assumes that the program takes input from cin and sends output to cout . The second command tells the program to take its input from the file named infile and to produce output in the file named outfile . The program should be able to support all of the above input/output options.

I l @ ve RuBoard

Категории