Dev C++ Include Stdio.h
(stdlib.h) C Standard General Utilities Library This header defines several general purpose functions, including dynamic memory management, random number generation, communication with the environment, integer arithmetics, searching, sorting and converting. C Library - h - The stdio.h header defines three variable types, several macros, and various functions for performing input and output. Library Variables. Input and Output operations can also be performed in C using the C Standard Input and Output Library (cstdio, known as stdio.h in the C language). This library uses what are called streams to operate with physical devices such as keyboards, printers, terminals or with any other type of files supported by the system.
- Include Stdio Visual Studio
- Dev C Include Stdio.h Code
- Stdio H
- C Stdio File
- Dev C Include Stdio.h In C
- Dev C Include Stdio.h Examples
- C++ Stdio
Now let's start from where we left off, 'The Hello World' code.
On compiling the above code, 'Hello World' gets printed on the screen.
So, we have just written a code which can print anything on the screen. Sounds good! Now, let's understand this code in detail so that we can print any other message.
Let's start from printf('Hello Worldn');
→ printf is a function which displays whatever is written inside the brackets ( )
on the screen.
We have used a word function, so let's discuss what it is.
A function is like a machine which takes something from us (not necessarily) and then performs an operation on it. In simple words, a function takes an input from the user and gives back an output.
In the above example, printf
is taking 'Hello Worldn' as input and in return, displaying 'Hello World' on the screen.
So, we gave 'Hello Worldn' to the printf
function and it printed (displayed) 'Hello World' on the screen without 'n'. So, let's discuss what it is.
n
is a special character called newline character which is used for changing lines or printing new lines. So, 'n' after the 'Hello World' changed the line or printed a new line. Let's run the following code for an example.
As you can see, 'n' printed a new line between 'Hello' and 'World'. So, 'n' is used to print a new line in our program.

So we are clear with the printf('Hello Worldn')
part, let's proceed further and discuss more about the code we have written.
;
→ Semicolon tells the compiler about the end of a statement. We need to put ';' at the end of every statement like function calls, variable declarations, etc.
So, by putting ';' at the end of printf('Hello Worldn')
, we have ended that statement there. Anything written after that will be a new statement. For example, printf('Hello Worldn'); return0;
is totally valid and C will treat both these as different statements even they are on a same line.
We have understood everything about the printf('Hello Worldn');
statement, let's learn about int main()
.
int main()
→ main is also a function. It is compiled first when a C code is executed that is, the execution of any C program starts from the main()
function. int
before main
means that the function will return (or give us back) an integer.
Since the execution of every C program starts from this main
function, all C programs must have this main()
function.
{ }
→ The curly braces ({ }) just after the main()
function encloses the body of the main()
function. It means that it represents what things are inside the 'main' or the body of the 'main'.
Till now, we know that to print 'Hello World' on the screen, we used printf
and to execute this statement, we put this statement inside the main
function (inside { }
after main) because C will execute the main
function and thus, the statements inside it will be executed. Let's move ahead and understand the rest of the code.
return 0
→ As mentioned earlier, the main
function returns an integer value (int main()
), therefore we are returning 0 here. return is a keyword which is used to return some value from a function. Returning 0 indicates that our program has been run successfully and we terminate our main function with this return statement.
You will go through a whole chapter on functions, so just keep this structure in your mind to write programs and you will understand all these in a much better way in the Function chapter.
→ stdio.h stands for standard input output. It is a library in C which contains definitions of functions such as 'printf'. Thus, it will tell the compiler how 'printf' should work. #include is a pre-processor which is used to link the program with stdio.h (pre-processors will be taught in later chapters).
#include <stdio.h>
So, the conclusion is - '#include' will make 'stdio.h' library available for use and then our computer will know what is 'printf'. 'stdio.h' contains the definitions of functions like 'printf'. The program will start its execution from the 'main' function and the execution of 'main' will make 'printf' to give messages on the screen. 'return 0' will return 0 and indicate that our program has been run successfully.
So, the format to write codes in C is like:
Let's try out some examples of printf.
Commenting
Comments are statements written inside code which are just ignored by the compiler while compiling our code. Comments are written to make our code more readable for humans.
Comments are written between '/* ... */'
or after //
.
Why Comments
As mentioned earlier, it makes our code more readable. Assume that you have written a software and after releasing it, you hired few good programmers for its maintenance. Without comments, it would be a very difficult job for them to understand your code. And most of the time it happens that the person who has written a code is not the one who is going to modify it. So, make a habit of writing good comments.
Comments are written after //
. These are single line comments. It means that if you change the line then the new line will not be the part of the comment.
Comments can be multiline also as used in the example given below. But we can't put one comment inside another eg.- /* This is a /*comment*/ */
is invalid.
I hope you are getting things because we are going to move one step further.
Taking Input from User
Let's try to understand the above code.
int a;
→ It is a statement which declares that the variable 'a' is an integer. And by this declaration, 'a' enters into the world of our program. Since 'a' is in our program, our computer will give some space in its memory for 'a'.
The next statement is printf
which we already know that it will print 'Enter an integer' on the screen.
After this, we have scanf
. It is another function like printf
. As printf
is used to display something on the screen, scanf
is used to take values from the keyboard. Its definition is also stored in the 'stdio.h' library.
Inside the scanf
, we have %d
and &a
. %d
is used for integers in C and here, it is telling that the scanf
will take an integer value from the keyboard.
&a
→ It means at the address of 'a'. As 'a' is in our program, it must be present somewhere in the memory of our computer and thus, it must occupy some space in the memory and this memory also has an address (you will learn about it later) and &a
is pointing to that address.
As stated above, scanf
function takes data from the user and assigns it to a variable and %d
written inside the scanf
is for taking the integer inputs, scanf('%d', &a)
will take the integer input from the keyboard, and if successful, store the value of the input at the address of 'a'. In short, it means that the value entered by the keyboard will be stored in the variable 'a'.
Now, 'a' will be like
a
or 'a' will store a value of 21 because 21 has been entered by the keyboard.
In printf('Entered value is : %dn' , a )
everything got printed as it is except %d
. As stated, '%d' is used for integers. Thus, the complier will look for value for '%d', which we are giving by 'a' after a comma(,). So, the value of the variable 'a' will be printed in place of '%d' in the printf
.
21 2
Entered value is : 21 and 2 and their sum is 23
We have declared two integers 'x' and 'y'. We are taking their values from the user by 'scanf'.
scanf('%d %d' ,&x,&y);
→ There are two '%d' inside 'scanf' to take two integers and store them at the address of 'x' and 'y' respectively.
int z = x+y;
→ We have declared a new integer variable 'z' and it is equal to the sum of the values of 'x' and 'y'. i.e. x+y.
printf('Entered value is : %d and %d and their sum is %dn' ,x,y,z );
→ Three '%d' are used and their values will be printed from 'x', 'y' and 'z' respectively.
Overall, we first declared two integers and took their values from the user. Then we declared one more variable 'z' and made it equal to 'x+y' and at last, we printed everything that we wished.

The overall conclusion is that we now know how to take input and make something appear on the screen. You will learn more in the next chapter but do solve questions based on these before going further to have a good control over this chapter.
In future, when writing long codes, make sure that you run your code from time to time while writing instead of completing your whole code and running at last. This will make debuging your code easier if you have made some errors.
Tells the preprocessor to treat the contents of a specified file as if they appear in the source program at the point where the directive appears.
Syntax
#include 'path-spec'
#include <path-spec>
Remarks
You can organize constant and macro definitions into include files and then use #include directives to add them to any source file. Include files are also useful for incorporating declarations of external variables and complex data types. The types may be defined and named only once in an include file created for that purpose.
The path-spec is a file name that may optionally be preceded by a directory specification. The file name must name an existing file. The syntax of the path-spec depends on the operating system on which the program is compiled.
For information about how to reference assemblies in a C++ application that's compiled by using /clr, see #using.
Both syntax forms cause that directive to be replaced by the entire contents of the specified include file. The difference between the two forms is the order in which the preprocessor searches for header files when the path is incompletely specified. The following table shows the difference between the two syntax forms.
Syntax Form | Action |
---|---|
Quoted form | The preprocessor searches for include files in this order: 1) In the same directory as the file that contains the #include statement. 2) In the directories of the currently opened include files, in the reverse order in which they were opened. The search begins in the directory of the parent include file and continues upward through the directories of any grandparent include files. 3) Along the path that's specified by each /I compiler option. 4) Along the paths that are specified by the INCLUDE environment variable. |
Angle-bracket form | The preprocessor searches for include files in this order: 1) Along the path that's specified by each /I compiler option. 2) When compiling occurs on the command line, along the paths that are specified by the INCLUDE environment variable. |
The preprocessor stops searching as soon as it finds a file that has the given name. If you enclose a complete, unambiguous path specification for the include file between double quotation marks (' '
), the preprocessor searches only that path specification and ignores the standard directories.
Include Stdio Visual Studio
If the file name that's enclosed in double quotation marks is an incomplete path specification, the preprocessor first searches the 'parent' file's directory. A parent file is the file that contains the #include directive. For example, if you include a file named file2 in a file named file1, file1 is the parent file.
Include files can be 'nested': An #include directive can appear in a file that's named by another #include directive. For example, file2 could include file3. In this case, file1 would still be the parent of file2, but it would be the 'grandparent' of file3.
Dev C Include Stdio.h Code
When include files are nested and when compiling occurs on the command line, directory searching begins in the directories of the parent file. Then it proceeds through the directories of any grandparent files. That is, searching begins relative to the directory that contains the source that's currently being processed. If the file isn't found, the search moves to directories that are specified by the /I (Additional include directories) compiler option. Finally, the directories that are specified by the INCLUDE environment variable are searched.
From the Visual Studio development environment, the INCLUDE environment variable is ignored. For information about how to set the directories that are searched for include files and library files, see VC++ Directories Property Page.
Stdio H
This example shows file inclusion by using angle brackets:
This example adds the contents of the file named STDIO.H to the source program. The angle brackets cause the preprocessor to search the directories that are specified by the INCLUDE environment variable for STDIO.H, after it searches directories that are specified by the /I compiler option.
The next example shows file inclusion by using the quoted form:
This example adds the contents of the file that's specified by DEFS.H to the source program. The quotation marks mean that the preprocessor first searches the directory that contains the parent source file.
Nesting of include files can continue up to 10 levels. When the nested #include is processed, the preprocessor continues to insert the enclosing include file into the original source file.
Microsoft Specific
To locate includable source files, the preprocessor first searches the directories that are specified by the /I compiler option. If the /I option isn't present, or if it fails, the preprocessor uses the INCLUDE environment variable to find any include files within angle brackets. The INCLUDE environment variable and /I compiler option can contain multiple paths, separated by semicolons (;). If more than one directory appears as part of the /I option or within the INCLUDE environment variable, the preprocessor searches them in the order in which they appear.
C Stdio File
For example, the command
causes the preprocessor to search the directory D:MSVCINCLUDE for include files such as STDIO.H. The commands
have the same effect. If both sets of searches fail, a fatal compiler error is generated.
If the file name is fully specified for an include file that has a path that includes a colon (for example, F:MSVCSPECIALINCLTEST.H), the preprocessor follows the path.
Dev C Include Stdio.h In C
For include files that are specified as #include 'path-spec'
, directory searching begins with the directory of the parent file and then proceeds through the directories of any grandparent files. That is, searching begins relative to the directory that contains the source file that contains the #include directive that's being processed. If there is no grandparent file and the file has not been found, the search continues as if the file name were enclosed in angle brackets.
Dev C Include Stdio.h Examples
END Microsoft Specific
C++ Stdio
See also
Preprocessor directives
/I (Additional include directories)