Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

What is function #include

+18 votes
asked Sep 5 by pratish vanakhade (230 points)

7 Answers

0 votes
answered Sep 5 by saranya d (140 points)

#include is a preprocessor in c program that includes the content of the other file to the source code where #include is declared 

+5 votes
answered Sep 5 by Peter Minarik (32,880 points)
edited Sep 15 by Peter Minarik

#include copies the content of an entire file to the location of the #include call.

In practice, it is most commonly used to include header files, that is to reference function prototypes, data types, constants, etc that are stored in a single file.

E.g.

#include <string.h>

will reference all the C library functions and constants that are related to C-string manipulations.

0 votes
answered Sep 13 by Legen-T-ask (140 points)

#include is an Header file which is inbuild command user cant change

its used to include the functions and many more like math.h & conio.h & stdio.h

#include <string.h>

0 votes
answered Sep 14 by Vinod Ahirwar (140 points)
C Language: #include Directive

This C tutorial explains how to use the #include preprocessor directive in the C language.

Description

In the C Programming Language, the #include directive tells the preprocessor to insert the contents of another file into the source code at the point where the #include directive is found. Include directives are typically used to include the C header files for C functions that are held outsite of the current source file.

Syntax

The syntax for the #include directive in the C language is:

#include <header_file>

OR

#include "header_file"

header_file

The name of the header file that you wish to include. A header file is a C file that typically ends in ".h" and contains declarations and macro definitions which can be shared between several source files.

Note

The difference between these two syntaxes is subtle but important. If a header file is included within <>, the preprocessor will search a predetermined directory path to locate the header file. If the header file is enclosed in "", the preprocessor will look for the header file in the same directory as the source file.

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 TechOnTheNet.com */

#include <stdio.h>

int main()

{

   /*

    * Output "TechOnTheNet began in 2003" using the C standard library printf function

    * defined in the stdio.h header file

    */

    printf("TechOnTheNet began in %d\n", 2003);

    return 0;

}

In this example, the program will output the following:

TechOnTheNet began in 2003

Header Files

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:

Header File Type of Functions

<assert.h> Diagnostics Functions

<ctype.h> Character Handling Functions

<locale.h> Localization Functions

<math.h> Mathematics Functions

<setjmp.h> Nonlocal Jump Functions

<signal.h> Signal Handling Functions

<stdarg.h> Variable Argument List Functions

<stdio.h> Input/Output Functions

<stdlib.h> General Utility Functions

<string.h> String Functions

<time.h> Date and Time Functions

You will find these header files very useful as you become more familiar with the C language.
0 votes
answered Sep 14 by Aditya Tiwari (210 points)

#include directive tells the preprocessor to insert the contents of another file into the source code at the point where the #include directive is found. Include directives are typically used to include the C header files for C functions that are held outsite of the current source file.

0 votes
answered Sep 14 by Amit Sharma (140 points)
#include function is a headr file which is use in code.

every header file has its specific work.

for ,example #include <string.h>is use for string operations and #include<math.h>is use for arithmetical operations.
0 votes
answered Sep 15 by Eman Sajid (140 points)
we use this preprocessor directive to add different library function
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...