Print to console....without any includes...

Is it possible to print an output without any include files or external libraries at all? Thanks
You'll need to do it in a platform specific way.

Libraries allow us to write portable code, but you're free to write platform specific code if you need to.

As you're posting in a Windows forum, I take you're running Windows. You will have to negotiate with the OS and won't have direct access to the hardware. You have to talk to a Windows library.
Last edited on
@kbw So is there a way for me write a function, similar to std::cout, that would not be platform specific? Thanks

@tributo ...neither of your posts make much sense, except for the fact that you are insulting my intelligence...
@kbw So is there a way for me write a function, similar to std::cout, that would not be platform specific? Thanks

The standard library is not platform specific. That's why you can use then everywhere.

You could write you own, but there isn't much point.
You are right, I know it is a complete waste of time, and there is not much of a point in doing it, but honestly, thinking about it there isn't much point to programming in general, people do it because it's fun (or maybe it's the money....) either way, I am doing because I am trying to learn about user defined operators, data types, and overloading operators, and I was trying to learn about the << operator which std::cout uses, I want to understand how cout works as most functions would follow something like the following func(VarToPrint); not func operator VarToPrint

All else aside, I am working on a (pointless) framework, without the use of other libraries. Honestly, time is nothing I am worried about. This is for enjoyment and educational purposes, believe it or not.

Anyways, sorry for the rant, could you point me to somewhere to start making my own Print function using operators, thanks!
Have you looked at the reference page? http://www.cplusplus.com/reference/ Shows a picture of how the streams break down under Input/Output Stream Library. May be something to look at before looking into making our own.
@ OP: First you should realize that the operator ("<<" in this case) and the object (std::cout) are separate entities. Operators are built into the C++ language, this is why you can overload the existing ones them but you can never add your own.

Each object in C++ has the ability to assign specific behavior to each operator. Technically you can have the "<<" operator perform addition in the context of your object if you wanted to, it is obnoxious but possible. The std::cout object is an instance of std::basic_ostream which is created by default and associated with the stream buffer of the systems default output device to eliminate the redundant typing that you have to do.

If you really want to look at the source code for this stuff then here is the link to the GCC mirror sites: https://gcc.gnu.org/mirrors.html
Thank you, I am aware that operators can be used for different purposes in different objects, and the cout is an object of basic_ostream, I am also aware that there are indeed ways to create your own operators, however I have no looked into it. Yet.

Thank you for the link, I will surely look into that!
m, I am also aware that there are indeed ways to create your own operators
no
-----------------------------------------------------------------------------
you can tell any built in operator to do what you want (as long as it involves more than just base types) but in c++ you cannot create your own operators like **, and for good reason
those are macros... not true operators
labeled operators, used like operators, declared in the class/struct as operators... looks like a duck, quacks like a duck, walks like a duck, it's a duck.
actually they are labeled as macros. that site is incorrectly calling them operators. and that logic isnt sound. if i make a class called Int, that takes an int, and can use ==, !=, <, >, <=, >=, +, -, ++... etc its not really an int. its a class wrapped around an int, even though it looks, acts, and is used like an int
MrProGamer121 wrote:
looks like a duck, quacks like a duck, walks like a duck, it's a duck.

That is a dangerous attitude to have when it comes to programming.
Topic archived. No new replies allowed.