How exactly does the ostream print out character on the screen without being OS specific? Or does the OS just read the characters from the stream and print them out themselves?
Any help would be appreciated.
How exactly does the ostream print out character on the screen without being OS specific? Or does the OS just read the characters from the stream and print them out themselves?
Any help would be appreciated.
Not 100% sure but I would expect that compilers for different OS's have a different implementation of these things.
As I understand it, being portable means that you can compile the exact same code for different platforms, but it doesn't mean that the compiler wouldn't implement your program in completely different ways.
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Thanks both of you. That is a question I have had for a long time. If could ask one more question that would be helpful. Does cin work the same way?
Almost everything that does any kind of I/O has to call an API in the OS because it needs to access hardware to do it. Even malloc() calls an API (i.e. HeapAlloc() in Windows).
The point of the standard I/O library is to hide the platform differences from the programmer. So the library is system-specific, but because it offers the same interface everywhere, you don't need to care.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
So the standard libraries arent always the same(i\o specificly)? If so then why does Bjarne Stroustrup give just one person credit?(not sure who)
The standard group define how the libraries work and the interface they have, but each compiler vendor implements these libraries themselves (ie, write all the code).
So each compiler has its own library, but they work in the same way. So as a C++ programmer, you can use the libraries, despite what compiler it is, and know the result to be the same everywhere it's compiled.
And it's I/O, not I\O.
Thanks for all the answers. That cleared alot of things up.
And the person Bjarne credits for the iostreams library would be the guy who came up with the original interface. Then there's the guy who came up with the STL idea of containers, iterators and algorithms. And then there's the many people on the standards committee who refined those interfaces.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law