Structure - Introduction to Structure
- Siddharth Sharma
- Nov 12, 2025
- 2 min read
Structure - Introduction to Structure
C में Structure एक user-defined data type है जिससे हम अलग-अलग data types के variables को एक साथ group करके एक नया data type बना सकते हैं।
यह सुविधा इसलिए उपयोगी होती है क्योंकि कभी-कभी हमें एक entity के बारे में multiple attributes (जैसे छात्र का नाम, रोल नंबर, और CGPA) एक साथ store करने होते हैं।
Structure data को logically organize करता है और complex data के साथ काम करना आसान बनाता है।
Structure का keyword है struct जिसे use करके हम structure define करते हैं।
आप इसे user-defined या derived data type भी कह सकते हैं क्योंकि programmer इसे खुद बनाता है।
Declaring Structure
Structure declare करने के लिए syntax होता है:

Syntax of Structure इसमें structure_name आपकी structure का नाम होता है जो C identifier rules के अनुसार होता है।
Curly braces {} के अंदर अलग-अलग data types के variables declare होते हैं जिन्हें structure के members कहते हैं।
Declaration के बाद एक semicolon (;) लगाना जरूरी होता है।
उदाहरण:

एक या अधिक structure variables declare करने के लिए:
struct Student s1, s2;
Initialisation of Structure
Structure variables के members को initialize करने के लिए dot (.) operator का उपयोग करते हैं।
उदाहरण:
c
s1.roll = 101;
strcpy(s1.name, "Rahul");
s1.cgpa = 9.1;आप एक structure variable को declare करते ही initialize भी कर सकते हैं:
struct Student s3 = {102, "Anita", 8.9};
Structure members को यूजर से input लेने के लिए scanf() और output के लिए printf() का उपयोग किया जाता है।
Structure की initialization और access करना variables जैसे ही होता है, बस dot operator के कारण थोड़ी syntax अलग होती है।
Summary Example

Key Points
Structure is उपयोगी जब एक से अधिक related data items को एक साथ store करना हो।
Structure को declare करने के बाद variables declare करें और फिर उन्हें initialize करें।
Dot operator से ही member access और initialization होता है।
Structure variables global या local दोनों scopes में हो सकते हैं।
Initialization के लिए curly braces के अंदर values भी डाल सकते हैं।
This combination of Hindi and English should help understand the concept clearly as per your preference.




Comments