I want to see source code of STL std::cout
function. I looked at iostream, but I've seen only "extern cout". So, I guess that it's defined somewhere in the library.
I downloaded source code from official site
I extracted it and did:
sh@sh-R528-R728:~/desktop/stl$ grep -F * | grep "cout"
but I got nothing.
What am I doing wrong? Where is the source code?
cin and cout are streams and do not exist in C. You can use printf() and scanf() in C.
std::cout is also not part of the STL.
The cout command is a data stream which is attached to screen output and is used to print to the screen, it is part of the iostream library.
Microsoft has open-sourced STL to allow it's users easy access to all the latest developments in C++ by trying out latest changes and improving pull requests by reviewing them.
If you happen to be using GCC, then libstdc++
is your C++ library. Its sources can be found on gcc.gnu.org. cout
is defined on line 58 of src/c++98/globals_io.cc
.
cout
is not part of the STL, so you won't find the source for cout
in the STL source.
You probably want to look for the source for your C++ standard library, which was based on the STL, but also contains iostreams. Where that is depends on what platform you're using.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With