How text is outputted internally depends on the operating system. Most operating systems provide a native API which allows access to all features provided by the operating system. The C runtime library will likely call functions from this native API in order to perform I/O operations.
For example, on Microsoft Windows, you can obtain the file handle for "standard output" by calling the function GetStdHandle
, which is exported by the DLL kernel32.dll
(which is part of the operating system). Afterwards, you can write to the returned file handle using WriteFile
. This function is also exported by kernel32.dll
. Both of these functions are intended to be called by C or C++ code, but can also be called by assembly code.
On other operating systems, such as Linux or MacOS, the interface provided by the operating system is different.
How the operating system implements these functions is an implementation detail and may change when a new version of the operating system is released. The operating system's implementation is probably mostly programmed in C or C++, with a bit of assembly language in a few places. If you want to see exactly how such things are implemented, you might want to consider taking a look at the source code of the Linux kernel and of the corresponding C runtime library.