Skip to main content

Posts

Showing posts from 2020

A simple echo program

The following small program accepts streams from the console and prints out as soon as we hit enter. #include template < typename In, typename Out > void Echo(In& in, Out& out) {     out << in.rdbuf(); } int main() {     Echo(std::cin, std::cout);     return 0; } So, the rdbuf() returns a pointer to the underlying  basic_streambuf  for the input stream and prints it out again on the console. The program runs in a loop until we break it by Ctrl+C.