5.1.26 · D1 · HinglishC Programming

FoundationsTypedef

1,407 words6 min read↑ Read in English

5.1.26 · D1 · Coding › C Programming › Typedef

Iss trick par trust karne se pehle, tumhe exactly pata hona chahiye ki ek type, ek declaration, ek variable name, ek *, ek struct, aur ek function pointer kya hote hain — pictures mein, sirf words mein nahi. Yeh page inhe sab zero se build karta hai, uss order mein jo parent note ko chahiye.


0. "Type" kya hota hai? (sabse pehla symbol)

Figure dekho: memory ke wahi 4 bytes alag-alag matlab rakh sakte hain depending on the type label unpar lagi ho. Label hi type hai; bits same hain.


1. Variable, naam, aur declaration

Neecha diya picture anatomy dikhata hai: left mein type, middle mein naam, right mein semicolon jo sentence khatam karta hai.


2. Asterisk * — "pointer to"

Address sirf memory ka ek house number hai. Figure mein, box p mein 5 nahi hai; usmein ek arrow (address) hai jo us box ki taraf point karta hai jisme 5 hai.


3. struct — ek naam ke neeche boxes ka bundle

Har baar "do words" likhna tedious hai, aur yahi woh itch hai jo typedef struct Point Point; scratch karta hai: yeh tumhe struct word chhod kar sirf Point p; likhne deta hai.


4. Function pointer — sabse ugly symbol, tamed

Figure ko left-to-right decode trick se padhdo: parentheses (*Operation) * ko naam ke saath group karte hain (matlab yeh pointer hai), trailing (int, int) kehta hai "two ints wali function ki taraf", aur leading int kehta hai "returning int".


5. #define — comparison ke liye imposter


Yeh topic ko kaise feed karte hain

Type is size plus interpretation

Declaration gives a box a name

Asterisk means pointer to

struct bundles boxes under a tag

Function pointer holds a functions address

Cover typedef read as declaration

typedef makes a new name for a type

hash define is blind text replace


Equipment checklist

Ek type kis cheez se bana hota hai (do cheezein)?
Bytes mein size plus bits interpret karne ka rule.
int x; mein, kaun sa word type hai aur kaun sa naam?
int type hai, x variable name hai.
typedef ke liye one-move decode trick kya hai?
typedef word cover karo, baaki ko variable declaration ki tarah padho; "variable name" hi naya type name hai.
Declaration mein * ka kya matlab hai, aur yeh kisse bind hota hai?
"Pointer to"; yeh naam se bind hota hai, base type se nahi.
int *a, b; mein a aur b kya hain?
a hai int *, b plain int hai.
Point p; ki jagah struct Point p; kyun likhna padta hai?
Tag Point struct namespace mein rehta hai, isliye full type name do words struct Point hai.
int (*Operation)(int,int) ko words mein padho.
Operation ek function ki taraf pointer hai jo do ints leta hai aur int return karta hai.
#define aur typedef mein core difference kya hai?
#define blind preprocessor text replacement hai; typedef ek real compiler-level type alias hai jo *-binds-to-name rule samajhta hai.

Connections

  • Parent: Typedef — yeh page har woh symbol supply karta hai jo woh note assume karta hai.
  • Structures in C — §3 se struct/tag foundation.
  • Pointers in C — §2 se * foundation.
  • Function Pointers — §4 mein tamed ugly type.
  • Linked Lists — jahan typedef struct node Node; pay off karta hai.
  • 5.1.26 Typedef (Hinglish) — same ideas Hinglish mein.