User Define Data type : Structures in hindi c कंप्यूटर भाषा में स्ट्रक्चर क्या होता है

c कंप्यूटर भाषा में स्ट्रक्चर क्या होता है User Define Data type : Structures in hindi :-
C language मे fundamental data type integer ,float,charterer और double |और user define data type array मे केवल एक ही type के data को store कर सकते है लेकिन हमे दो – दो से अधिक types के data को store करना हो तब structure data type को use किया जाता है |
Structure यह data type है जिसमे दो दो से अधिक datatype के data को store कर सकते है |
उदाहरण के लिए:
Date : ये day,month,year का समूह होता है |
Address : ये Building name, floor ,street name,city और pin code का समूह होता है |
Time : ये hours ,minutes और seconds का समूह होता है |
Book : ये name,writer , title और price का समूह होता है |Structure एक powerful tool है जो इस तरह के data types को handle के लिए |इस article मे structure define,Structure variable declaration और Structure member access  को स्टडी करेगे |

Structure Definition :

जिस तरह array को use करने के पहले उसे define करना पड़ता है उसी प्रकार Structure के variable को use करने पहले define करना पड़ता है |इसका syntax है :-
struct Structure_name
{
  datatype variabel_name 1;
  data type variable_name 2;
  data type variable_name 3;
  data type variable_name n;
};
इसमें :
struct : ये एक keyword है जो की Structure को define करता है |
Structure_name : ये Structure का नाम होता है जिसे Structure declaration मे use होता है |
datatype variabel_name 1 : इन्हें Structure के  data elements /members कहते है |
syntax Explanation :
1.Structure की body( जिसमे structure member को define किया जाता है ) को semicolon से terminate किया जाता है |
2.Structure body मे सभी structure member  की definition individual statement होते है इसलिए सभी statement semicolon से terminate होते है |
उदहारण के लिए;
उदहारण 1.
struct date
{
int day;
char month [10];
int year;
};
इस उदहारण मे ,date एक Structure data type है जिसमे तीन variables है जिनके datatype अलग -अलग है |
1. int day[2] ; ये एक variable है जिसका data type integer  है |
2.char month[10] ; ये एक array  है जिसका  data type character  है |
3. int year ;ये एक variable  है जिसका data type integer  है |
उदहारण 2.
struct address
{
int house_no[4];
int floor ;
char street [15];
char city [10];
int pincode ;
};
इस उदहारण मे ,address  एक Structure data type है जिसमे पांच variables है जिनके datatype अलग -अलग है |
1. int house ; ये एक variable है जिसका data type integer है | जिसमे address का house no store होगा |
2.char floor ; ये एक variable है जिसका data type integer है |इसमें floor no store होगा |
3.char street [15] ;ये एक string है जिसमे street का नाम store होगा  |
4.char city [10]; ये एक string है जिसमे city का नाम store  होगा  |
5.int pincode ; ये variable है जिसमे pincode store होगा |
Structure Declaration:
Structure  Definition के बाद ,हम variable को declare करते है | variable (जिसका type Structure  होता है) को उसी प्रकार से declare किया जाता है जिस प्रकार fundamental variable को declare करते है |इसका syntax होता है :-
struct Structure_name variable_name ;
इसमें
struct : ये Structure का keyword होता है |
Structure_name : ये Structure का नाम होता है जो Structure definition मे define होता  है |
variable_name : ये variable का नाम है जिसे प्रोग्राम मे use किया जाता है |
Structure memory मे Structure declartion के बाद ही space occupy करेगे |इसका मतलब है की Structure_definition के memory मे जब तक space occupy नहीं होता जब तक variable को declare नहीं किया जाये |
Structure declaration को दो जगह कर सकते है :-
Structure definition के साथ : इसका उदाहरन है :
struct address
{
int house_no[4];
int floor ;
char street [15];
char city [10];
int pincode ;
} address 1,address 2,address 3;
या
struct
{
int house_no[4];
int floor ;
char street [15];
char city [10];
int pincode ;
}address 1,address 2,address 3;
इस तरह के declartion मे Structure_name ऑप्शनल होता है |इसमें तीन variable declare होगे जिसक नाम address 1,address 2,address 3 है |
लेकिन इस syntax को बहुत कम  इस्तेमाल किया जाता है क्योकि
1. Structure_name नहीं होने के कारण programmer इसे main() मे use नहीं कर सकता है |इस उदहारण मे address 1,address 2,address 3 के अलावा address 4 declare नहीं हो सकता है|
2. इसमें variable main() function से पहले declare होगे जिससे ये variable globle type होगे |इसे कोई भी दूसरा function use कर सकता है |यह re usability की प्रॉब्लम create हो जाएगी|Structure member Access :
जभुमे Structure के किसी variable मे value को assign करना हो या Structure के variable की value को use करना हो तब हम इसके  लिए operator(MEMBER OPERATOR ‘.’) को  यूज़ करेगे |इसका syntax है :

variable_name . Structure member variable _name = assign value ;

scanf और printf function statement के rules/syntax fundamental data type की तरह ही होते है |

उदहारण है :-

struct

 

 

{
int house_no[4];
int floor ;
char street [15];
char city [10];
int pincode ;
}address 1,address 2,address 3;
main()
{
address 1.house_no=343;
address 1.floor=1
address 1.street=Ram gali ;
address 1.city=jaipur ;
address 1.pincode=302008;
printf(“%d”,address 1.floor);
printf(“%[. .]”,address 1.street);
………………………………………….;
………………………………………….;
आदि
}Structure Example :
#include<stdoio.h>
#incluide<conio.h>
struct date
{
int day;
char month [10];
int year;
};
void main()
{
struct date date_1;
printf(“Enter day”);
scanf(“%d”,&date_1.day);
printf(“Enter Month”);
scanf(“%s”,date_1.month);
printf(“Enter Year”);
scanf(“%d”,&date_1.year);
Printf(“Your Date is “);
printf(“%d”,date_1.day);printf(“/”);printf(“%s”,date_1.month);printf(“/”);printf(“%d”,date_1.year);
getch();
}आउटपुट होगा :
Enter day 12
Enter Month December
Enter year 2018
Your Date is 12/December/2018