Typedef in c hindi

Typedef in c hindi

typedef सी प्रोग्रामिंग एक रिजर्व्ड कीवर्ड है. typedef कीवर्ड का उपयोग मौजूदा डाटा टाइप्स के लिए डाटा टाइप उपनाम या नए नाम डाटा टाइप बनाने के लिए किया जाता है। यह काम्प्लेक्स डाटा टाइप्स की प्रोग्राम डिक्लेरेशन को आसान कर सकता है, typedef प्रोग्राम कोड को अधिक रीडेबल बनाता है, और प्रोग्राम डेटा टाइप्स को एब्स्ट्रैक्ट बना सकता है।

Typedef in c hindi

Basic use of typedef data type in C programs.

सी ,प्रोग्राम में typedef कीवर्ड आपको किसी मौजूदा डाटा टाइप के लिए एक नया नाम डिफाइन फीचर्स प्रदान करता है। यह काम्प्लेक्स typedef डाटा टाइप की डेफिनिशन या प्रोग्राम कोड को अधिक रिडेबल बनाने के लिए विशेष रूप से उपयोगी हो सकता है।

typedef program examples in C.

#include <stdio.h>

typedef unsigned int number;

int main() {

    number num = 78;

    printf(“\n num is : %u”, num);

    return 0;

}

ऊपर दिए गए सी प्रोग्राम उदाहरण में, नंबर को unsigned int के उपनाम के रूप में डिफाइन किया गया है।

Using typedef data type with structures in a program.

typedef डाटा टाइप का उपयोग अक्सर स्ट्रक्चर डाटा टाइप के साथ किया जाता है. ताकि typedef प्रोग्राम दोहरावदार और लॉन्ग टाइप की डिक्लेरेशन से बचा जा सके।

C program example without typedef.

#include <stdio.h>

struct Values {

int p;

int q;

};

int main() {

struct Values m1;

m1.p = 1;

m1.q = 2;

printf(“\n The Values is – (%d, %d)\n”, m1.p, m1.q);

return 0;

}

C program example with typedef.

#include <stdio.h>

typedef struct {

int p;

int q;

} Values;

int main() {

Values m1;

m1.p = 1;

m1.q = 2;

printf(“\n the values with structure – (%d, %d)\n”, m1.p, m1.q);

return 0;

}

ऊपर दिए गए सी प्रोग्राम उदाहरण में, वैल्यूज को struct { int p; int q; } के लिए उपनाम के रूप में डिफाइन किया गया है।

Using typedef data types with pointers.

typedef डाटा टाइप का उपयोग पॉइंटर टाइप्स के लिए उपनाम डाटा टाइप बनाने के लिए किया जा सकता है. जिससे प्रोग्राम कोड अधिक रिडेबल हो जाता है।

Example of typedef data types with pointers.

#include <stdio.h>

typedef int* int_pointer;

int main() {

int q = 9;

int_pointer p = &q;

printf(“\n the pointer values is – %d”, *p);

return 0;

}

यहाँ, int_पॉइंटर को int* के लिए उपनाम के रूप में डिफाइन किया गया है।

Using typedef data types with pointers.

सी प्रोग्राम में फ़ंक्शन पॉइंटर्स को डिक्लेअर करना और उपयोग करना काम्प्लेक्स हो सकता है। यहाँ आपको typedef डाटा टाइप इस प्रक्रिया को आसान बनाता है।

Example of typedef data types with pointers.

#include <stdio.h>

typedef void (*function_pointer)(int);

void printInteger(int inte) {

printf(“\n the pointer is – %d”, inte);

}

int main() {

function_pointer fp = printInteger;

fp(9);

return 0;

}

इस फंक्शन पॉइंटर उदाहरण में, function_pointer को void (*)(int) के लिए एक उपनाम के रूप में डिफाइन किया गया है।

सी में Arrays के साथ typedef डाटा टाइप का उपयोग करना।

typedef का उपयोग ऐरे प्रकारों के लिए उपनाम बनाने के लिए भी किया जा सकता है।

Using typedef data types with Arrays in C.

#include <stdio.h>

typedef int IntegerArray[7];

int main() {

IntegerArray arry = {1, 2, 3, 4, 5, 6, 7};

for (int p = 0; p < 7; p++) {

printf(“\n the array value is – %d “, arry[p]);

}

printf(“\n”);

return 0;

}

यहाँ, IntegerArray को int[7] के लिए एक उपनाम के रूप में डिफाइन किया गया है।

Using typedef data types with enums.

typedef डाटा टाइप का उपयोग एनुमेरशन डाटा टाइप के लिए उपनाम डाटा बनाने के लिए किया जा सकता है, जिससे प्रोग्राम सोर्स कोड अधिक रिडेबल हो जाता है।

Example of typedef with enums.

#include <stdio.h>

typedef enum {

YES,

NO,

INVALID

} Choice;

int main() {

Choice ch = YES;

printf(“\n the choice is – %d\n”, ch);

return 0;

}

इस enum तो typedef प्रोग्राम उदाहरण में, Choice को enum { YES, NO, INVALID } के लिए एक उपनाम डाटा टाइप के रूप में डिफाइन किया गया है।

सी प्रोग्राम में typedef को स्ट्रक्चर्स और Enums के साथ संयोजित करना।

आप अधिक जटिल प्रकार परिभाषाओं के लिए typedef को स्ट्रक्चर्स और enums के साथ संयोजित कर सकते हैं।

Use of typedef data type in C.

C प्रोग्रामिंग में typedef डाटा टाइप को मौजूदा डाटा टाइप्स के लिए उपनाम डाटा टाइप बनाने में किया जाता जाता है. इसके साथ काम्प्लेक्स typedef डिक्लेरेशन को सरल बनाने और प्रोग्राम कोड को अधिक रिडेबल बनाने के लिए एक पॉवरफुल टूल है।

Some key points about typedef.

सी प्रोग्राम में typedef प्रिमिटिव डाटा टाइप, जैसे,  स्ट्रक्चर, पॉइंटर्स, फ़ंक्शन पॉइंटर्स, ऐरे और एनम्स के लिए प्रकार उपनाम डाटा टाइप बनाना।

जटिल typedef डाटा टाइप प्रोग्राम प्रकार की डिक्लेरेशन को सरल बनाना।

typedef प्रोग्राम सोर्स कोड की रीडेबल बनाना और प्रोग्राम मेंटेनेंस में सुधार करना।

टाइपडेफ़ डाटा टाइप का प्रभावी ढंग से उपयोग करने से आपको स्पष्ट और अधिक रखरखाव योग्य C प्रोग्राम कोड बनाने में सहायता मिलती है।