https://www.rakeshmgs.in/search/label/Template
https://www.rakeshmgs.in


๐ŸŒž เค†เคช เคธเคญी เคตिเคœिเคŸเคฐ्เคธ เค•ो เค›เค  เคฎเคนाเคชเคฐ्เคต เค•ी เคนाเคฐ्เคฆिเค• เคถुเคญเค•ाเคฎเคจाเคं ๐Ÿ™๐ŸŒผ

RakeshMgs

Pointers in C Programming in Hindi

Updated:

 

Introduction to Pointers

Pointers เคตो variables เคนोเคคे เคนै เคœो เคฆूเคธเคฐे variables เค•े address เค•ो store เค•เคฐเคคे เคนै। เคœैเคธा เค•ी เค†เคชเค•ो เคชเคคा เคนै เคนเคฐ variable เค•ा memory เคฎें เคเค• unique address เคนोเคคा เคนै। เคฏे address hexadecimal form เคฎें เคนोเคคा เคนै। เค‡เคธเคฒिเค เค‡เคธ address เค•ो เค†เคช เค•िเคธी normal variable เคฎें store เคจเคนीं เค•เคฐ เคธเค•เคคे เคนै।

Address in C

เค•िเคธी เคญी variable เค•े address เค•ो store เค•เคฐเคตाเคจे เค•े เคฒिเค เค†เคช pointer variable create เค•เคฐเคคे เคนै। เคฎाเคจ เคฒीเคœिเคฏे เค†เคชเคจे เคเค• variable create เค•िเคฏा เคนै। เค‡เคธ variable เค•ा เคจाเคฎ Age เคนै เค”เคฐ เค†เคชเคจे เค‡เคธเคฎें 55 value assign เค•เคฐเคตाเคฏी เคนै।

เค‡เคธ variable เค•ी memory เคฎें location (address) 21F เคนै। เค…เคฌ เคฏเคฆि เค†เคช เคšाเคนे เคคो เค‡เคธ address เค•ो เคเค• pointer variable เคฎें store เค•เคฐเคตा เคธเค•เคคे เคนै।

เค†เค‡เค เค•िเคธी เคญी variable เค•े memory address เค•ो เคฆेเค–เคจे เค•े เคฒिเค เคเค• เค›ोเคŸा เคธा program เคฒिเค–ें เคœिเคธे เคนเคฎ เค…เคชเคจे program เคฎें define เค•เคฐเคคे เคนैं।

	
	
#include<stdio.h> void main() { int var = 7; printf ("Value of the variable var is: %d\n", var); printf ("Memory address of the variable var is: %x\n", &var); }

output

Value of the variable var is: 7
Memory address of the variable var is: bcc7a00

เค†เคชเคจे เคซ़ंเค•्เคถเคจ scanf() เคฎें เคญी เคฆेเค–ा เคนोเค—ा, เคนเคฎ เค•िเคธी เคญी variable var เค•े เคฒिเค user เค‡เคจเคชुเคŸ เคฒेเคจे เค•े เคฒिเค &var เค‰เคฒ्เคฒेเค– เค•เคฐเคคे เคนैं।

	
	
scanf("%d", &var);

เค‡เคธเค•ा เค‰เคชเคฏोเค— variable var เค•े address เคชเคฐ เคฏूเคœเคฐ เค‡เคจเคชुเคŸेเคก เคตैเคฒ्เคฏू เค•ो เคธ्เคŸोเคฐ เค•เคฐเคจे เค•े เคฒिเค เค•िเคฏा เคœाเคคा เคนै।.

Concept of Pointers

เคœเคฌ เคญी เค•िเคธी เคช्เคฐोเค—्เคฐाเคฎ เคฎें เคเค• เคตैเคฐिเคเคฌเคฒ declare เค•िเคฏा เคœाเคคा เคนै, เคคो เคธिเคธ्เคŸเคฎ เคเค• เคฒोเค•ेเคถเคจ allocates เค•เคฐเคคा เคนै เคฏाเคจी เคฎेเคฎोเคฐी เคฎें เค‰เคธ เคตैเคฐिเคเคฌเคฒ เค•े เคฒिเค เคเค• address เค†เคตंเคŸिเคค เค•िเคฏा เคœाเคคा เคนै, เคคाเค•ि เคจिเคฐ्เคงाเคฐिเคค เคตैเคฒ्เคฏू เค•ो เคนोเคฒ्เคก เค•िเคฏा เคœा เคธเค•े। เค‡เคธ location เค•ा เค…เคชเคจा address เคจंเคฌเคฐ เคนै, เคœिเคธे เคนเคฎเคจे เค…เคญी เคŠเคชเคฐ เคฆेเค–ा เคฅा।

เค†เค‡เค เคฎाเคจ เคฒेเคคे เคนैं เค•ि เคธिเคธ्เคŸเคฎ เคจे variable เค•े เคฒिเค เคฎेเคฎोเคฐी เคฒोเค•ेเคถเคจ 80F allocate เค•िเคฏा เคนै।

int a = 10;


เคนเคฎ variable เคจाเคฎ เค•ा เค‰เคชเคฏोเค— เค•เคฐเค•े เคฏा เค‡เคธเค•े address 80F เค•ा เค‰เคชเคฏोเค— เค•เคฐเค•े value 10 เคคเค• เคชเคนुँเคš เคธเค•เคคे เคนैं।

เคธเคตाเคฒ เคฏเคน เคนै เค•ि เคนเคฎ เคเค• variable เค•ा เค‰เคชเคฏोเค— เค•ैเคธे เค•เคฐ เคธเค•เคคे เคนैं เคฏเคน เคชเคคा เคนै? เคšूँเค•ि เคฎेเคฎोเคฐी เคเคก्เคฐेเคธ เคญी เคธिเคฐ्เคซ เคจंเคฌเคฐ เคนोเคคे เคนैं, เค‰เคจ्เคนें เค•िเคธी เคฆूเคธเคฐे เคตेเคฐिเคเคฌเคฒ เคฎें เคญी เค…เคธाเค‡เคจ เค•िเคฏा เคœा เคธเค•เคคा เคนै। เคตे variable เคœिเคจเค•ा เค‰เคชเคฏोเค— เคฎेเคฎोเคฐी address เค•ो เคฐเค–เคจे เค•े เคฒिเค เค•िเคฏा เคœाเคคा เคนै, เคชॉเค‡ंเคŸเคฐ เคšเคฐ เค•เคนเคฒाเคคे เคนैं।

เคเค• เคชॉเค‡ंเคŸเคฐ เคตैเคฐिเคเคฌเคฒ เค‡เคธเคฒिเค เค•ुเค› เคญी เคจเคนीं เคนै เคฌเคฒ्เค•ि เคเค• เคตैเคฐिเคเคฌเคฒ เคนै เคœो เค•िเคธी เค…เคจ्เคฏ เคตैเคฐिเคเคฌเคฒ เค•ा เคชเคคा เคฐเค–เคคा เคนै। เค”เคฐ เคเค• เคชॉเค‡ंเคŸเคฐ เคตैเคฐिเคเคฌเคฒ เค•ा เคฎाเคจ เคฆूเคธเคฐे เคฎेเคฎोเคฐी เคฒोเค•ेเคถเคจ เคฎें เคธ्เคŸोเคฐ เคนो เคœाเคคा เคนै।


Advantages of Using Pointers

  1. Pointers เค•ी เคฎเคฆเคฆ เคธे เค†เคช dynamically memory allocate เค•เคฐ เคธเค•เคคे เคนै।
  2. Pointers เค•ी เคฎเคฆเคฆ เคธे เค†เคช data structures (linked-list, stack, queue) create เค•เคฐ เคธเค•เคคे เคนै।
  3. Pointers use เค•เคฐเคจे เคธे program เค•ा execution time เค•เคฎ เคนो เคœाเคคा เคนै।
  4. Pointers เค•ी เคฎเคฆเคฆ เคธे เค†เคช functions เคธे เคเค• เคธे เค…เคงिเค• values return เค•เคฐ เคธเค•เคคे เคนै।
  5. Pointers เค•ी เคฎเคฆเคฆ เคธे argument passing เค•े เคฆौเคฐाเคจ เค†เคช variable เค•ी copy เค•े เคฌเคœाเคฏ original variable เคชเคฐ เค•ाเคฎ เค•เคฐ เคธเค•เคคे เคนै।
  6. Pointers เค•े เคฆ्เคตाเคฐा large data เค•ो search เค”เคฐ sort เค•เคฐเคจा เคฌเคนुเคค เค†เคธाเคจ เคนोเคคा เคนै

เคฏเคฆि pointers เค•ो properly use เคจा เค•िเคฏा เคœाเคฏे เคคो เค‡เคธเค•े เค•ुเค› dis-advantages เคนोเคคे เคนै।

Disadvantages of Using Pointers

  1. เค•เคˆ เคฌाเคฐ pointers เค•ी เคตเคœเคน เคธे program เคฎें เคเคธी error เค† เคœाเคคी เคนै เคœिเคธे diagnose เค•เคฐเคจा เคฌเคนुเคค difficult เคนोเคคा เคนै।
  2. Pointers เค•ी เคตเคœเคน เคธे memory เคฎें leaks create เคนो เคœाเคคे เคนै।
  3. เคฏเคฆि run time เค•े เคฆौเคฐाเคจ pointers เค•ो hold เค•เคฐเคจे เค•े เคฒिเค extra memory เคจा เคนो เคคो program crash เคนो เคœाเคคा เคนै।
  4. Pointers เค•ी เคฎเคฆเคฆ เคธे restricted memory เค•ो access เค•िเคฏा เคœा เคธเค•เคคा เคนै।

เค†เคชเค•ो เค†เคฐ्เคŸिเค•เคฒ เค•ैเคธा เคฒเค—ा? เค…เคชเคจी เคฐाเคฏ เค…เคตเคถ्เคฏ เคฆें
Please don't Add spam links,
if you want backlinks from my blog contact me on rakeshmgs.in@gmail.com