It's programming time!/C++/include "stdafx.h"

From Create Your Own Story

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

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

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. Like, my purse! It includes my keys. The keys were not part of my purse, but if I do not put them in, then when I get to my scooter, I cannot start it! So, I make sure to #include "scooterkeys". Does this help explain?

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.

Now, the "stdafx.h" is specific to the IDE (Look up IDE, I am not explaining what an IDE is...). I personally use Visual Studio. This is a Visual Studio inclusion. Others may use something like "using namespace std;". In this case, the stdafx has the information that Visual Studio will commonly want to use. Sorry, I can't explain it other than to say, if you use Visual Studio, this needs to be at the beginning.

Personal tools