Programming with C

⌘K
  1. Home
  2. Docs
  3. Programming with C
  4. Input/Output statements
  5. Pre-processor directives
  6. Source file inclusion directive

Source file inclusion directive

The source file inclusion directive “include” tells the preprocessor to replace the directive with the contents of the file specified in the directive.

Three different ways,

 #include<name-of-the-file

It searches the prespecified list of directories for the source file and text embeds the entire content of the source file in place of file itself

#include “name-of-file”

It first searches the file in the current working directory. If the search us not supported or if the search fails, the search will be carried out in the prespecified list of directories. If the search still fails, it will show the error “unable to include name of file”

#include token-sequence

Searches the file as in point 1 or in point 2 depending upon the form of the directive to which it matches after the preprocessing token sequence is processed.

Example

#define STR(x) #x
#include STR(stdio.h)
int main()
{
	printf("Third form of source file inclusion");
	return 0;
}

Output

Third form of source file inclusion

Views: 0

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments