Do std::cout the hard way.

closed account (2hfG1hU5)
If I wanted to do a basic output to the console without any header files, how would I go about this? I don't have any practical reason for doing this, it is just that I figured it would help me learn lots about the language.
Last edited on
Well if you use mingw, go in its folder, and go to: "include\c++".
You can find the file called "iostream" with no .h, and open the file.

Now you can start doing the scavenger hunt of getting all of iostreams dependencies like: #include <bits/c++config.h> , and #include <ostream> , but I doubt that it will even work even if you get all of it.
Other than Pascal, C/C++ doesn't know anything about in-/output. The reason is, that C was developed to write an operating system, namely UNIX, and thus the compiler couldn't have any knowledge about the target IO-system.

If you want to use some more basic IO-routines than those offered by <iostream>, then have a look at open(2), read(2), write(2), close(2) and others. These are standard UNIX IO-system calls which may (or may not?) be also accessible on MS-Windows. (I've never programed on this platform, sorry). But they're definitely available on MinGW. UNIX (Linux, ...) based <iostream> uses them to compose the <iostream> library.

(The numbers in parentheses are UNIX manual section names. Use f.e.
man 2 read
)
Topic archived. No new replies allowed.