Header File in C (C में हैडर फाइल)
- Siddharth Sharma
- Oct 6, 2025
- 2 min read
Introduction / परिचय
C programming language में, header file वह file होती है, जिसमें function declarations, macro definitions, और data type definitions को store किया जाता है. Header files का extension हमेशा .h होता है.
Header files को program में #include preprocessor directive के through include किया जाता है, जिससे हम standard या user-defined functions को अपने program में use कर सकते हैं.
Syntax / सिंटैक्स
Header file को दो तरीकों से include किया जाता है:
// Standard header file (system library):
#include <filename.h>
// User-defined header file (same directory):
#include "filename.h"
<filename.h> — System की predefined या standard header file के लिए
"filename.h" — User-defined यानि खुद बनाई गई header file के लिए
Types of Header Files / हैडर फाइल के प्रकार
C में header files दो प्रकार की होती हैं:
Standard/Header files (Pre-existing) – यह files compiler के साथ आती हैं और standard library functionalities provide करती हैं.
User-defined header files – Programmer खुद अपने requirements के हिसाब से बनाता है.

Common Standard Header Files / मुख्य स्टैंडर्ड हैडर फाइल्स
Header File | Use / उपयोग |
<stdio.h> | Input/output functions (जैसे printf(), scanf()) |
<stdlib.h> | General utilities (जैसे atoi(), malloc()) |
<string.h> | String manipulation (जैसे strcpy(), strlen()) |
<math.h> | Math functions (जैसे pow(), sqrt()) |
<ctype.h> | Character test/conversion |
<time.h> | Time/date functions |
<limits.h> | Data type limits |
Example:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}इस example में <stdio.h> header file से printf() function use किया गया है.
Advantages / फायदे
Code reuse – बार-बार वही code कई जगह लिखने से बचते हैं
Maintenance easy – Changes सिर्फ़ header file में करो, automatic सब programs में लागू होगा.
Readability बढ़ती है, structure clear रहता है
User-defined Header File कैसे बनाएं?
Suppose आपको खुद का function बार-बार use करना है, तो आप अपने function का declaration एक header file (जैसे myheader.h) में रख सकते हैं, और definition को अलग .c file में.
Create myheader.h:
int add(int, int); // function declarationCreate mycode.c:
#include "myheader.h"
int add(int a, int b) {
return a + b;
}Main Program:
Conclusion / निष्कर्ष
C में header files code को modular, readable, और reusable बनाने के लिए जरूरी हैं. Standard और user-defined दोनों types की header files programs में अलग-अलग functionalities add करने के लिए use की जाती हैं.




Comments