1

Say we have

std::cout << "Something";

How exactly is this working? I just wanna make sure I understand this kinda well and from what I've been reading is it okay to say that basically the insertion operator inserts the string literal "Something" into the standard output stream? But like what happens after that? Where does the standard output stream lead idk can anyone explain this?

Emma
  • 11
  • 1
  • 1
    The I/O mechanisms on modern operating systems are relatively complex, and there are a lot of moving parts, so it's good to know which phases you're interested about most. Are you asking about what happens within the C++ standard library as a consequence of calling `operator< – nanofarad Sep 06 '21 at 18:41
  • You're basically right. You can think `< stdout.txt` or pipe into other processes `./my_process | head -10 | less` – Kostas Sep 06 '21 at 18:41
  • The best way to learn how `iostream` works is to read the standard and the code (for instance `g++`). Learn about [streambuf](https://en.cppreference.com/w/cpp/io/basic_streambuf) and the rest. And then write some `ostream` for yourself. For instance, [here](https://github.com/amanuellperez/mcu/blob/master/src/dev/dev_LCD_ostream.h) you can find a basic implementation of an LCD as an `std::ostream`. – Antonio Sep 06 '21 at 19:18
  • Does this answer your question? [Question std::cout in c++ how exactly does the stream work?](https://stackoverflow.com/questions/69079644/question-stdcout-in-c-how-exactly-does-the-stream-work) – Kane Sep 06 '21 at 21:14

0 Answers0