Why white spaces are not considered as white spaces when we declare header file in c++?

Viewed 565

When we declare header file in c++. It is not recommended to insert white spaces between angular braces '<' '>' and header file name. If we insert it comes out with an error. I have tried in Xcode and various other IDE's

// It is perfectly valid ( in c++ )
#include <iostream> 

but 

// It is invalid
#include < iostream >
1 Answers

There's no header file named iostream that begins and ends with a space character, so that's why you get an error.

The name, all of the characters, inside the <> or "" when you use #include designates a header name (with most implementations it refers to a physical file name)

If you include one of your own header files with e.g.

#include " file.h "

it will look for a file with the name file.h (that begins and ends with a space).

That's a different filename than any of these two:

#include "file.h "
#include "file.h"
Related