When a C/C++ program is written, you write #include <stdio.h> or #include <iostream> at the top of program but have you ever wondered what are they. They are the Header Files, the first thing that you have to do in program is to understand the concept of these guys and you need to include these header files in the very first line of your program which appears like this: #include <header file>
| Green line is a Header File |
Header Files contains all set of functions that you are going to use in the program, if you do not use it than you have to type all the things i.e. complete coding of that particular function. For an instance, when you use printf function it will display the output in C. Similar is the case with scanf which is a function you use to input in C and similarly with cin and cout which are also a function made for input and output.
So the whole code written to make up those functions are now in specific header files. To save time you just include them or you may say you link them to your program so that you do not have to write the complete programming of that particular function again and again, this just saves time and increases efficiency and re-usability, isn't it?
![]() |
| A graphical representation of the grammar of C/C++ |
'Either you are dumb or I'm going nuts!'
Extensions
.header files sometimes having a .h extension, .hpp extension, or no extension at all. When compiler compiles the program, it first links those header files to the program which is linked to the function you are going to use so there you can see is a chain relation, and now it knows what function you are using.
Assignments:
This was a concept, no assignments needed.
The QuickSEnd:
Edited by Zain Ul Mustafa at 12:30 am

Very well defined article :)
ReplyDeleteNice way of delivering the information, thanks!
ReplyDeleteThanks for your feedback, friend :)
Delete