O'Reilly logo

Hands-On System Programming with C++ by Dr. Rian Quinn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The basics of stream

Unlike the C-style printf() and scanf() functions, C++ IO uses streams (std::ostream for output and std::istream for input) that leverage the << and >> operators. For example, the following code outputs Hello World to stdout using a non-member << overload of basic_ostream for const char * strings:

#include <iostream>int main(){    std::cout << "Hello World\n";}> g++ -std=c++17 scratchpad.cpp; ./a.outHello World

By default, the std::cout and std::wcout objects, which are instantiations of std::ostream, output data to the standard C stdout, with the only difference being that std::wcout provides support for Unicode, while std::cout provides support for ASCII. In addition to several non-member overloads, C++ provides the following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required