Storage Class in C Language की जानकारी हिन्दी में

इस आर्टिकल में हम storage class in C programming के बारे में जानेगें । Storage class एक तरह की information होती है जो हम variable declaration के टाइम ही पास करते हैं। ये data type की तरह ही होती है। इससे से हमारे complier को वेरीअबल के बारे में addition information पता चलती है जैसे कि वेरीअबल की लाइफ कितनी होगी। Data type के अलावा जो information हम वेरीअबल को देते हैं उसको storage class कहते हैं।

storage class in C language in indi

Definition of Storage class in C programming

यहाँ हम details में ये जानेगें कि storage class कैसे काम करती है और कहाँ पर इसको declaration किया जाता है। ये कहाँ लिखा जाता है और इसको use करने की क्या जरूरत होती है जबकि हम पहले से ही data type का use करते आ रहे हैं।
Storage class defines the scope ( visibility ) and lifetime of a varriable within a c programe.
C programe में हमारा वेरीअबल कहाँ से कहाँ तक available होगा और उसकी visibility, lifetime क्या होगी। हम कौन से कोड के बाद उसको use नहीं कर सकते या उसकी वैल्यू को हम access नहीं कर सकते , ये सारी चीजें हमें storage class से पता चलती है।
हम varriable declaration करते समय data types लिखते हैं। जिसमें हम ये बताते हैं कि वेरीअबल के अंदर कौन सी वैल्यू स्टोर हो रही है जैसे integer , float , character आदि। लेकिन यदि हमें कुछ ऐसी information देनी है जैसे कि वो varriable कहाँ तक available होगा और उसकी वैल्यू को कहाँ से access कर सकते हैं। ये सारी information को हम अपने complier को देने के लिए storage class का प्रयोग करते हैं । ये सब हमें variable declaration के समय करना होता है।
Example :-
auto int res =5;

Types of Storage class in C language

1. Auto
2. Register
3. Static
4. Extern

C Language में Tokens क्या होते हैं

Variable in C Programming पूरी जानकारी हिन्दी में

 

1. Auto Storage Class

The auto storage class is the default storage class for all local variables.
Auto storage क्लास वो होती है जब हम variable बनाते समय कोई भी स्टॉरिज क्लास को declare नहीं करते हैं। ये by default class है जो अपने आप स्टोर हो जाती है। By default जो स्टॉरिज क्लास हमारे वेरीअबल के साथ link हो जाती है उसको auto storage class कहते हैं।
इसमें जिस particular part के लिए हमने variable बनाया था ये उसी part of the programe तक ये variable सीमित रहता है। Part of the programe हमारे curly brackts ( { } ) होते हैं जिसमें हमने define किया था। हम उस variable की वैल्यू को उसी part में access कर सकते हैं। अगर programe में हमें कहीं ओर उस वैल्यू की जरूरत होती है तो हम उस part of the programe से बाहर हम उस वैल्यू को access नहीं कर सकते।
Example :- int month ; और auto int month; ये दोनों same है , इसमें कोई फर्क नहीं है।

2. Register storage class

When we want a variable to load faster , we declare it in register storage class.
अगर हमें कोई ऐसा variable चाहिए जिसको हम अपने प्रोग्राम में बार बार use करना है तो हम चाहते हैं कि वो variable बहुत ज्यादा फास्ट काम करे। उसके अंदर की वैल्यू हमें बहुत जल्दी प्राप्त हो सके। उसके लिए हम register storage class का प्रयोग करते हैं। हम इसको register storage clas में declare करते हैं इसलिए ये कभी कभी CPU register में variable को create कर देता है।
जब हम कोई variable बनाते हैं तो वो हमारे hard disk में एक location पर save हो जाता है। लेकिन जब हम किसी वेरीअबल को register storage class देते हैं तो वो हमारे CPU के register , जो बहुत छोटी memory होती है उसमें save हो जाता है।

3. Static Storage Class

Variable which need to retain their value even outside their scopes are declared under static class.
जो हमारा part of the programe होता है , हमारा वेरीअबल उसी में काम करता है। हमें कुछ ऐसे variable बनाने है जिसको हम उस part of the programe से बाहर कहीं भी प्रयोग कर सके। Multiple times उसको extract और access करने के बाद भी उसकी वैल्यू जो है वो हमेशा static रहे तो उसके लिए हम static class का प्रयोग करते हैं।

4. Extern Storage Class

Variables which are declared in a scope/block can be used in another block, are created using extern storage class. Extern also helps to share variables from one file to another file.
जो part of the programe है उसमे आपने कोई variable बनाया है तो आप उसको कहीं ओर use नहीं कर सकते। अगर आप उसको बाहर use करना चाहते हैं तो आप उसको Extern storage class में declare करते हैं।
मान लीजिए आपने कोई बड़ी application बनाई है जिसमें अलग-अलग c programe की file लग रही है । आपने किसी एक programe file में एक variable बनाया हुआ था और उसकी वैल्यू आपको किसी दूसरे c programe में फाइल use करनी है तो उस टाइम आप उसको extern storage class में declare करते हैं।
जैसे:- extern int area ;
C Language सीखने में बहुत ही आसान है। इस आर्टिकल में आपको storage class in c language के बारे में बताया गया था। उम्मीद करता हूँ आपको इसके बारे में अच्छी तरह से समझ आ गया होगा। अगर अपने c language से related पिछले आर्टिकल नहीं पढे हैं तो आप पहले उनको जरूर पढे। इस से रिलेटेड अगर आपका कोई सवाल है तो आप comment में पूछ सकते हो।

Add a Comment

Your email address will not be published. Required fields are marked *