# C Programming Tutorial

## C #include

The #include preprocessor directive is used to paste code of given file into current file. It is used include system-defined and user-defined header files. If included file is not found, compiler renders error.

By the use of #include directive, we provide information to the preprocessor where to look for the header files. There are two variants to use #include directive.

1. #include
2. #include "filename

The #include tells the compiler to look for the directory where system header files are held. In UNIX, it is \usr\include directory.

The #include "filename" tells the compiler to look in the current directory from where program is running.

#### #include directive example

Let's see a simple example of #include directive. In this program, we are including stdio.h file because printf() function is defined in this file.

```
#include<stdio.h>
int main(){
printf("Hello C");
return 0;
}

```

Output:

Hello C

#### #include notes:

Note 1: In #include directive, comments are not recognized. So in case of #include <a//b>, a//b is treated as filename.

Note 2: In #include directive, backslash is considered as normal text not escape sequence. So in case of #include #include <a\nb>, a\nb is treated as filename.

Note 3: You can use only comment after filename otherwise it will give error.

#### Example

Let's look at an example of how to use #include directives in your C program.

In the following example, we are using the #include directive to include the stdio.h header file which is required to use the printf standard C library function in your application.

```
/* Example using #include directive by C programming */

#include <stdio.h>

int main()
{
/*
* Output "c programming began in 2018" using the C standard library printf function
* defined in the stdio.h header file
*/
printf("c programming began in %d\n", 2018);

return 0;
}

```

In this example, the program will output the following:

c programming began in 2018

This is a list of the header files that you can include in your program if you want to use the functions available in the C standard library: