It's programming time!/C++/include iostream

From Create Your Own Story

#include "stdafx.h"
#include <iostream>

int main()
{
std::cout << "Hello world!" << std::endl;
return 0; }

Okay, this has two parts:

#include
<iostream>

The first one, #include, does exactly like it sounds. It includes something. So, when the program is made (compiled), it will say "Hey, put this thing in the program, since it tells the program what to do". Easy, yes?

Maybe not. No worries. Just remember, it includes something additional, that is not written in your normal code. Of course, the # is actually called a preprocessor directive, and even I had to look that up. It says to process something before. Anyways, confusing, I know. I won't worry about that now, but may dive into it in another page. If you want to see a list of all the standard preprocessor directives, you can check The list of preprocessor directives! Exciting, I know.

Anyways, in this case, this line includes:

<iostream>

Now, the < and > just surround the file you need to "include", in this case, iostream. Different files do different things. Some are created by you, others are part of your program creation program (I use visual studio, so everything will be towards that). In this case, the iostream file says how to handle the inputs, from like keyboard and mouse, and outputs, like to your printer or screen. That is why it is io-stream: io for input output, stream for the constant signals that the io stuff sends or receives.

Hey, don't ask me to explain everything...this is for programming, not teaching you how io works, or how computers work, or whatever. Just imagine they are always talking, so the iostream tells stuff you use to put things in and stuff you use to see what was put in how to talk to each other.

Personal tools