c
  1. c-include

C #include Preprocessor Directive

Syntax

#include <header_file_name>

Example

#include <stdio.h>

int main() {
   printf("Hello, World!");
   return 0;
}

Output

The output of the above program will be:

Hello, World!

Explanation

The #include preprocessor directive is used to include a header file in a C program. A header file contains declarations for functions, variables, and other constructs that can be used by the program. The syntax for using the #include directive is #include <header_file_name>, where header_file_name is the name of the header file that needs to be included in the program.

Use

The #include directive is used in C programming to include header files containing function prototypes, constant definitions and variables that are used in the program. By including these header files, developers can write more concise and modular code that can be reused in other programs.

Important Points

  • The #include directive is a preprocessor directive in C programming language.
  • The header files typically have an extension .h.
  • There are two types of header files, system header files and user-defined header files.
  • The syntax for including a user-defined header file is #include "header_file_name".
  • The C standard library provides a set of standard header files that can be included in the program using the #include directive.

Summary

The #include directive in C programming language is an important preprocessor directive and provides a way to include header files in the program. Header files contain declarations for functions, variables and other constructs that can be used by the program. Understanding the syntax and use of this directive is essential for any C programmer who wants to write modular, reusable and efficient code.

Published on: