C - Structure in Hindi




C भाषा में विभिन्न प्रकार के डेटा को स्टोर करने के लिए structures का उपयोग किया जाता है उदाहरण के लिए, आप छात्र हैं आपका नाम एक स्ट्रिंग है और आपका फोन नंबर और रोल नंबर integer हैं इसलिए, यहां नाम, पता और फोन नंबर उन विभिन्न प्रकार के डेटा हैं यहां, संरचना picture में आती है।

Structure का उपयोग करके हम एक record को तैयार कर सकते है structure ये एक अलग-अलग data types का कलेक्शन होता है structure का इस्तेमाल करने के लिए 'struct' keyword का इस्तेमाल किया जाता है ये array के जैसा ही होता है।

एक संरचना के प्रत्येक element को एक member कहा जाता है structure के साथ काम करना बहुत ही आसान है क्योकि ये array जैसा होता है और यह डिफरेंट डाटा टाइप का collection होता है आइये अब हम देखते है की structure को कैसे डिफाइन किया जाता है और कैसे इसका use किया जाता है।

Syntax

struct structureName
{
   //member definitions
};

चलिए सी भाषा में संरचना का एक सरल उदाहरण देखें।

Example Code

#include<stdio.h>
#include <string.h>    
struct employee      
{   int id;      
    char name[50];      
}e1;  //declaring e1 variable for structure    
int main( )    
{    
   //store first employee information    
   e1.id=105;    
   strcpy(e1.name, "Rahul Sharma");//copying string into char array    
   //printing first employee information    
   printf( "employee 1 id : %d\n", e1.id);    
   printf( "employee 1 name : %s\n", e1.name);    
return 0;  
}  

Example Result

employee 1 id : 105
employee 1 name : Rahul Sharma