Item 1. Switching Streams

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


More Exceptional C++
More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions
ISBN: 020170434X
EAN: 2147483647
Year: 2001
Pages: 118
Authors: Herb Sutter

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net