Standard Library Functions In C - सी में फंक्शन लाइब्रेरी
- _Romeyo Boy_
- 17 नव॰ 2021
- 5 मिनट पठन
अपडेट करने की तारीख: 20 नव॰ 2021

इस ट्यूटोरियल में, आप सी में मानक लाइब्रेरी फ़ंक्शंस के बारे में जानेंगे।अधिक विशेष रूप से, वे क्या हैं, सी में विभिन्न लाइब्रेरी फ़ंक्शंस और उन्हें अपने प्रोग्राम में कैसे उपयोग करें।
सी मानक लाइब्रेरी फ़ंक्शंस या केवल सी लाइब्रेरी फ़ंक्शन सी प्रोग्रामिंग में अंतर्निहित (Built-In) फ़ंक्शंस हैं।
इन कार्यों के प्रोटोटाइप और डेटा परिभाषाएं उनकी संबंधित हेडर फ़ाइलों में मौजूद हैं। इन फ़ंक्शंस का उपयोग करने के लिए हमें अपने प्रोग्राम में हेडर फ़ाइल को शामिल करना होगा।
For Example ;
यदि आप printf( ) फ़ंक्शन का उपयोग करना चाहते हैं, तो हेडर फ़ाइल <stdio.h> को शामिल किया जाना चाहिए। तभी हम printf( ) फंक्शन का उपयोग कर सकते हैं।
#include <stdio.h> int main() { printf("Catch me if you can.");
}
What Is Library Functions?

सी में स्टैंडर्ड फंक्शन लाइब्रेरी उप-पुस्तकालयों का एक विशाल पुस्तकालय है, जिनमें से प्रत्येक में कई कार्यों के लिए कोड होता है। इन पुस्तकालयों का उपयोग करने के लिए, प्रत्येक पुस्तकालय को हेडर फाइलों के उपयोग के माध्यम से व्यापक पुस्तकालय में लिंक करना आवश्यक होता हैं।
इन फ़ंक्शंस की परिभाषाएँ उनकी संबंधित हेडर फाइलों में मौजूद हैं। इन फ़ंक्शंस का उपयोग करने के लिए, हमें प्रोग्राम में हेडर फ़ाइल को शामिल करना होगा।
हम #include <filename.h> का उपयोग करके अपने C प्रोग्राम में हेडर फाइल्स को शामिल करते हैं। जब भी प्रोग्राम चलाया और निष्पादित किया जाता है, तो संबंधित फाइलों को सी प्रोग्राम में शामिल किया जाता है।
Intrinsic Functions Or Math Functions
मानक गणितीय संचालन करने के लिए जैसे वर्गमूल ( जैसे √ x ), निरपेक्ष मान और इसी तरह, अंतर्निहित (Built-In) प्रोग्राम जिन्हें लाइब्रेरी फ़ंक्शन कहा जाता है, कंपाइलर के साथ उपलब्ध होता हैं।
कोष्ठक (parentheses) में आवश्यक संख्या में तर्कों के साथ उनके नामों का उल्लेख करके इन फंक्शन्स का उपयोग एक्सप्रेशन में किया जा सकता है।
Advantages Of Using C library functions ( सी फंक्शन लाइब्रेरी का उपयोग करने के लाभ )

01}. They work ( वे काम करते हैं )
लाइब्रेरी फ़ंक्शंस का उपयोग करने के सबसे महत्वपूर्ण कारणों में से एक यह है कि वे काम करते हैं। ये फ़ंक्शन कई कठोर परीक्षणों से गुज़रे हैं और उपयोग में आसान हैं।
02}. The functions are optimized for performance ( फ़ंक्शंस को प्रदर्शन के लिए अनुकूलित किया गया है)
चूंकि, फ़ंक्शन "मानक लाइब्रेरी"(Standard Library) फ़ंक्शन हैं, डेवलपर्स का एक समर्पित समूह लगातार उन्हें बेहतर बनाता है। इस प्रक्रिया में, वे अधिकतम प्रदर्शन के लिए अनुकूलित सबसे कुशल कोड बनाने में सक्षम हैं।
03} It saves considerable development time ( यह काफी विकास समय बचाता है )
चूंकि सामान्य फ़ंक्शन (General Function) जैसे स्क्रीन पर प्रिंट करना, वर्गमूल की गणना करना, और बहुत कुछ पहले ही लिखा जा चुका है। आपको उन्हें एक बार फिर से बनाने की चिंता नहीं करनी चाहिए।
04}.The functions are portable ( फ़ंक्शन पोर्टेबल हैं )
वास्तविक दुनिया की लगातार बदलती जरूरतों के साथ, आपके आवेदन के हर समय, हर जगह काम करने की उम्मीद है। और, ये फंक्शन लाइब्रेरी आपकी मदद करते हैं कि वे हर कंप्यूटर पर एक ही काम करते हैं।\
Significance Of Standard Library Functions ( मानक फंक्शन लाइब्रेरी का महत्व )
01}. Usability ( प्रयोज्य )
मानक लाइब्रेरी फ़ंक्शन प्रोग्रामर को सी बिना संकलक (Compiler) में उपलब्ध पूर्व-मौजूदा कोड का उपयोग करने की अनुमति देते हैं, उपयोगकर्ता को कुछ बुनियादी कार्यों को करने के लिए तर्क प्राप्त करके अपने स्वयं के कोड को परिभाषित करने की आवश्यकता होती है।
02}. Flexibility ( लचीलापन )
सी में मानक लाइब्रेरी फ़ंक्शन का उपयोग करते समय मामूली संशोधन ( Slight Modifications) करके प्रोग्रामर द्वारा विभिन्न प्रकार के कार्यक्रम बनाए जा सकते हैं।
03}. User-Friendly Syntax ( उपयोगकर्ता के अनुकूल वाक्य रचना )
हम पहले ही फंक्शन इन सी ट्यूटोरियल में चर्चा कर चुके हैं कि फंक्शन्स के सिंटैक्स को समझना और उसका उपयोग करना कितना आसान है।
04}. Optimization And Reliability ( अनुकूलन और विश्वसनीयता )
सी में सभी मानक लाइब्रेरी फ़ंक्शन को अधिकतम दक्षता के साथ इष्टतम आउटपुट (Optimal Output) उत्पन्न करने के लिए कई बार परीक्षण किया गया है ताकि इसे उपयोग करने के लिए विश्वसनीय बनाया जा सके।
05}. Time-saving ( समय बचाने वाला )
कोड की कई पंक्तियों को लिखने के बजाय, ये फ़ंक्शन प्रोग्रामर को पहले से मौजूद फ़ंक्शंस का उपयोग करके समय बचाने में मदद करते हैं।
06}. Portability ( सुवाह्यता )
आप जिस डिवाइस पर काम कर रहे हैं, उस पर ध्यान दिए बिना सी कंपाइलर में मानक लाइब्रेरी फ़ंक्शन उपलब्ध हैं। ये फ़ंक्शन एक ही अर्थ को व्यक्त करते हैं और इसलिए ऑपरेटिंग सिस्टम या प्रोग्रामिंग वातावरण की परवाह किए बिना एक ही उद्देश्य की पूर्ति करते हैं।
Example; Square Root Using sqrt( ) Function
मान लीजिए, आप किसी संख्या का वर्गमूल निकालना चाहते हैं।
किसी संख्या के वर्गमूल की गणना करने के लिए, आप sqrt( ) लाइब्रेरी फ़ंक्शन का उपयोग कर सकते हैं। फ़ंक्शन को math.h हेडर फ़ाइल में परिभाषित किया गया है।
#include <stdio.h> #include <math.h> int main() {
float num, root;
printf("Enter a number: ");
scanf("%f", &num);
// Computes the square root of num and stores in root.
root = sqrt(num);
printf("Square root of %.2f = %.2f", num, root);
return 0;
}
Output;
जब आप प्रोग्राम चलाते हैं, तो आउटपुट होगा:
Enter a number: 12
Square root of 12.00 = 3.46
Header File Library ( हैडर फ़ाइल लाइब्रेरी )
आमतौर पर उपयोग किए जाने वाले हेडर फ़ाइल के कुछ कार्य इस प्रकार हैं लाइब्रेरी फंक्शन्स निम्नलिखित कुछ इस प्रकार हैं -
<ctype.h>
<math.h>
<stdio.h>
<stdlib.h>
<string.h>
<time.h>
<assert.h>
<complex.h>
<float.h>
<limits.h>
<conion.h>
<stdarg.h>
<signal.h>
<setjmp.h>
<errno.h>
01 | <ctype.h>
इस हेडर फ़ाइल में सभी कैरेक्टर हैंडलिंग फ़ंक्शन परिभाषित किए गए हैं।
Function | Data Type Returned | Task |
<ctype.h> | | |
isalnum(c) | int | Determine if argument is alphanumeric. Return nonzero value if true; 0 otherwise. |
isalpha(c) | int | Determine if argument is alphanumeric. Return nonzero value if true; 0 otherwise. |
isascii(c) | int | Determine if argument is an ASCII character, Return nonzero value if true; 0 otherwise. |
iscntr(c) | int | Determine if argument is an ASCII control character . Return nonzero value if true; 0 otherwise. |
isdigit(c) | int | Determine if argument is a decimal digit. Return nonzero value if true; 0 otherwise. |
isgraph(c) | int | Determine if argument is a graphic printing ASCII character. Return nonzero value if true; 0 otherwise. |
islower(c) | int | Determine if argument is lowercase. Return nonzero value if true; 0 otherwise. |
isodigit(c) | int | Determine if argument is an octal digit. Return nonzero value if true; 0 otherwise. |
isprint(c) | int | Determine if argument is a printing ASCII character. Return nonzero value if true; 0 otherwise. |
ispunct(c) | int | Determine if argument is a punctuation character. Return nonzero value if true; 0 otherwise. |
isspace(c) | int | Determine if argument is a whitespace character. Return nonzero value if true; 0 otherwise. |
isupper(c) | int | Determine if argument is uppercase. Return nonzero value if true; 0 otherwise. |
isxdigit(c) | int | Determine if argument is a hexadecimal digit. Return nonzero value if true; 0 otherwise. |
toascii(c) | int | Convert value of argument to ASCII. |
tolower(c) | int | Convert letter to lowercase. |
toupper(c) | int | Convert letter to uppercase. |
02 | <math.h>
math.h हेडर विभिन्न गणितीय फ़ंक्शन और एक मैक्रो को परिभाषित करता है।गणित से संबंधित सभी फ़ंक्शन इस हेडर फाइल में होता हैं।
Function | Data Type Returned | Task |
<math.h> | | |
acos(d) | double | Return the arc cosine of d. |
asin(d) | double | Return the arc sine of d. |
atan(d) | double | Return the arc tangent of d. |
atan2(d1,d2) | double | Return the arc tangent of d1/d2. |
ceil(d) | double | Return a value rounded up to the next higher integer. |
cos(d) | double | Return the cosine of d. |
cosh(d) | double | Return the hyperbolic cosine of d. |
exp(d) | double | Raise e to the power d. |
fabs(d) | double | Return the absolute value of d. |
floor(d) | double | Return a value rounded down to the next lower integer. |
fmod(d1,d2) | double | Return the remainder of d1/d2 (with same sign as d1). |
labs(1) | long int | Return the absolute value of 1. |
log(d) | double | Return the natural logarithm of d. |
log10(d) | double | Return the logarithm (base 10) of d. |
pow(d1,d2) | double | Return d1 raised to the d2 power. |
sin(d) | double | Return the sine of d. |
sinh(d) | double | Return the hyperbolic sine of d. |
sqrt(d) | double | Return the square root of d. |
tan(d) | double | Return the tangent of d. |
tanh(d) | double | Return the hyperbolic tangent of d. |
03 | <stdio.h>
यह एक मानक Input/Output हैडर फ़ाइल होता है जिसमें इनपुट/आउटपुट फ़ंक्शन घोषित किए जाते हैं।
Function | Data Type Returned | Task |
<stdio.h> | | |
fclose(f) | int | Close file f. Return 0 if file is successfully closed. |
feof(f) | int | Determine if an end-of-file condition has been reached. If so, return a nonzero value; otherwise, return 0. |
fgetc(f) | int | Enter a single character form file f. |
fgets(s,i,f) | char* | Enter string s, containing i characters, from file f. |
fopen(s1,s2) | file* | Open a file named s1 of type s2.Return a pointer to the file. |
fprint(f,....) | int | Send data items to file f. |
fputs(c,f) | int | Send a single character to file f. |
fputs(s,f) | int | Send string s to file f. |
fread(s,i1,i2,f) | int | Enter i2 data items, each of size i1 bytes, from file f to string s. |
fscanf(f......) | int | Enter data items from file f. |
fseek(f,1,i) | int | Move the pointer for file f a distance 1 bytes from location i. |
ftell(f) | long int | Return the current pointer position within file f. |
fwrite(s,i1,i2,f) | int | Send i2 data items, each of size i1 bytes from string s to file f. |
getc(f) | int | Enter a single character from file f. |
getchar(void) | int | Enter a single character from the standard input device. |
gets(s) | char* | Enter string s from the standard input device. |
printf(....) | int | Send data items to the standard output device. |
putc(c,f) | int | Send a single character to file f. |
putchar(c) | int | Send a single character to the standard output device. |
puts(s) | int | Send string s to the standard output device. |
rewind(f) | void | Move the pointer to the beginning of file f. |
scanf(....) | int | Enter data items from the standard input device. |
04 | <stdlib.h>
इस फ़ाइल में सामान्य फ़ंक्शन (Common Functions) होते हैं जो C प्रोग्राम में उपयोग किए जाते हैं।
Function | Data Type Returned | Task |
<stdlib.h> | | |
abs(i) | int | Return the absolute value of i. |
atof(s) | double | Convert string s to a double-precision quality. |
atoi(s) | int | Convert string s to an integer. |
atol(s) | long | Convert string s to a long integer. |
calloc(u1,u2) | void* | Allocate memory for an array having u1 elements, each of length u2 bytes. Return a pointer to the beginning of the allocated space. |
exit(u) | void | Close all files and buffers and terminate the program. (Value of u is assigned by the function, to indicate termination status). |
free(p) | void | Free a block of allocated memory whose beginning is indicated by p. |
malloc(u) | void* | Allocate u bytes of memory. Return a pointer to the beginning of the allocated space. |
rand(void) | int | Return a random positive integer. |
realloc(p,u) | void* | Allocate u bytes of new memory to the pointer variables p. Return a pointer to the beginning of the new memory space. |
srand(u) | void | Initialize the random number generator. |
system(s) | int | Pass command string s to the operating system. Return 0 if the command is successfully executed, return a nonzero value typically -1. |
05 | <string.h>
सभी स्ट्रिंग संबंधित फ़ंक्शन इस हेडर फ़ाइल में हैं। स्ट्रिंग्स को वर्णों (Character) की एक सरणी के रूप में परिभाषित किया गया है। एक वर्ण सरणी के बीच का अंतर और एक स्ट्रिंग यह है कि एक स्ट्रिंग को एक विशेष वर्ण '\0' के साथ समाप्त किया जाता है।
Function | Data Type Returned | Task |
<string.h> | | |
strcmp(s1,s2) | int | Compare two strings lexicographically. Return a negative value if, s1<s2; 0 if s1 and s2 are identical; & a positive value if s1>s2. |
strcmpi(s1,s2) | int | Compare two strings lexicographically, without regard to case. Return a negative value if s1<s2; 0 if s1 and s2 are identical; and a value of s1>s2. |
strcpy(s1,s2) | cha | |
| | |
06 | <time.h>
दिनांक (Date) और समय (Time) प्रबंधन फ़ंक्शन (Handling Functions) को परिभाषित करता है।
Function | Data Type Returned | Task |
<time.h> | | |
difftime(11,12) | double | Return the time difference 11~12, where 11 and 12 represent elapsed time beyond a designated base time (See the time function). |
time(p) | long int | Return the number of seconds elapsed beyond a designated base time. |
07 | <assert.h>
यह एक एक्सप्रेशन के मूल्य की जाँच करता है जिसकी हम सामान्य परिस्थितियों में सत्य (True) होने की उम्मीद करते हैं। यदि एक्सप्रेशन एक गैर-शून्य (Non-Zero) मान है, तो assert मैक्रो कुछ नहीं करता है। इसमें डायग्नोस्टिक फ़ंक्शन शामिल हैं।
08 | <complex.h>
जटिल (Complex) संख्याओं में हेरफेर (Manipulating) करने के लिए का एक सेट होता हैं।
09 | <float.h>
फ़्लोटिंग-पॉइंट लाइब्रेरी के कार्यान्वयन-विशिष्ट (Implementation-Specific) गुणों को निर्दिष्ट करने वाले मैक्रो स्थिरांक (Macro Constants) को परिभाषित करता है।
10 | <limits.h>
प्रत्येक कंप्यूटर प्लेटफॉर्म पर संख्यात्मक डेटा (Numerical Data) प्रकार की सीमा को परिभाषित करने के लिए कक्षाएं (Classes) शामिल हैं।
11 | <conio.h>
यह कंसोल इनपुट/आउटपुट हेडर फाइल होता हैं।
12 | <stdarg.h>
इस हेडर फ़ाइल में चर तर्क फ़ंक्शन घोषित किए गए हैं।
13 | <signal.h>
इस फ़ाइल में सिग्नल (Signal) हैंडलिंग फ़ंक्शन घोषित किए गए हैं।
14 | <setjmp.h>
इस फ़ाइल में सभी जंप फ़ंक्शन (Jump Functions) शामिल हैं।
15 | <locale.h>
इस फ़ाइल में स्थानीय फ़ंक्शन (Locale Function) शामिल हैं।
16 | <errno.h>
इस फाइल में एरर (Error) हैंडलिंग फंक्शन दिए गए हैं।
Where, ( कहां, )
c - character type argument
d - double precision argument
f - file argument
i - integer argument
l - long integer argument
p - pointer argument
s - string argument
u - unsigned integer argument
An asterisk(*) denotes a pointer.
Commentaires