What does the # mean before the include?

That’s the question I had been asked a few months ago while on the phone with an interviewer from the MathWorks. I didn’t have a clue. All I knew was that you typed it all the time when you wanted to make sure you could use the printing functions in your main function. I finally wanted to put this question to rest, so I did a little research.

The # sign in C++ is a directive that says “handle this with the preprocessor” while the include statement means “make everything in the provided file available to this program” [1].

The “<” and “>” tell the preprocessor that the file located inside the angle brackets is located in the standard search path [1].

We may ask: “Exactly what does the #include do?  It copies the content of the file specified inside the quotation marks or the angle brackets, and places it in the file at the location where the #include appears [2].

References:

[1] “What does #include <stdio.h> stand for in c program?” Yahoo! Answers. April 2, 2008. http://answers.yahoo.com/question/index?qid=20080103071957AAKM9jX

[2] “Preprocessor”. April 3, 2008. http://en.wikipedia.org/wiki/Preprocessor

Leave a Reply