Pointer in c in Hindi | c in pointer with examples in Hindi

Pointer in c in Hindi | c in pointer with examples in Hindi

Pointer in c :- c Pointers Vo Variables Hote Hai Jo Dusre Variables ke Address ko store karte hai | Jesa ki aapko pta hai ki har variable ka memory me ek unique address hota hai | ye address hexa decimal form mei hota hai | isliye is address ko aap kisi bhi normal variable me store nhi kar sakte hai |

Pointer Basics

Kisi bhi Variable ke address ko store karwane ke liye aap pointer variable create karte hai | for example aap man lijiye aapne ek variable create kiya hai | is variable ka name Student_Age hai or aapne isme 30 value assign karwayi hai | to is variable ki memory mei location (address) 50F hai | ab yadi aap chahe to is address ko ek pointer variable me store karva sakte hai |

for example

int student_age,*pointer_var;

Student_age = 30
pointer_var = &Student_age

Pointer in c in Hindi ko samanjh ne ke liye ham examples ko dekhte hai.

Pointer in c programming with examples

Advantages of Pointer  
  • Pointers ki help se aap dynamically memory allocate kar sakte hai|
  • Pointers ki help se aap data structures ( linked-list,stack, queue) create kar sakte hai|
  • Pointers ki help se aap Function se ek se jyada values return kar sakte hai |
  • pointers ki help se argument passing ke douran aap variable ki copy ke badle original variable par kam kar sakte hai|
  • pointers istemal karne se program ka execution time kam ho jata hai |
  • Pointers ke duvara large data ko search or sort karna bahut aashan hota hai|

Using Pointers

Declaring  Pointers 

C me pointers ko declare karne ke liye sabse pahle aap data type declare karte hai | Esa lsliye kiya jata hai kyoki int type ka pointer varaible keval int type ke variables ka hi address store kar sakta hai |

data_type *pointer_name;
  • Data_type Matlab Like Int , float
  • Aap Asterisk(*) operator ko pointers declare karne ke liye istemal karte hai |
  • Iskebad pointer variable ka name declare karte hai
structure with examples in Hindi

Initializing Pointers 

C Programing me pointers initialize karne ke liye sabse pahle aap pointer variable ko likhte hai | ( Initialization part mei pointer variable ko bina asterisk operator (*) ke likha jata hai |

pntr_variable = &variable_name;

Iske bad aap ampersand operator yani address(&) (ise address of operator bhi kaha jata hai ) define karte hai | is operator ke bad aap bina koi space diye variable ka name likhte hai

Example 1:

#include<stdio.h>
int main()
{
    int age = 33;
    int *pntr;
    pntr = &age;
 
    printf(“Address of age variable is : %d”,pntr);
    
    printf(“Value of age variable is : %d”,*pntr);
}

Aap Uper Diye gye pointers output ke duvara ek variable ka address or uski value print karwayi gyi hai|

Output:

Address of age variables is : -1074204644;
Value of age variables is : 33 

Pointer to Structure

Structure variables ke pointers bhi create kiye ja sakte hai | ye usi tarah create kiye jate hai jese ki aap kisi normal varable ke pointers create karte hai |

Example 2:

#include<stdio.h>
 

/* Employee structure declaration */
struct Employee
{
    int Id;
    int Phone;
};

int main()
{

   /* Creating variable of Employee structure */
   struct Employee e1;
 
   struct Employee *emp;

   emp = &e1;

   emp->Id=101;
   emp->Phone = 237434839;

   printf(“Employee Id : %dn”,emp->Id);
   printf(“Employee Phone : %dn”,emp->Phone);

   return 0;
}

Output :

Employee Id : 101
Employee Phone : 2374334839

Pointers and Strings

Ham Example 3 me dikhte hai ki ham string ko pointers se kese print karate hai |

Example 3:

#include <stdio.h>
int main()
{
    char str[100];
    char *p;

    printf("Enter any string: ");
    fgets(str, 100, stdin);

    p=str;

    printf("The input string is: ");
  
    while(*p!='\0')
        printf("%c",*p++);

    return 0;
}

Output:

Enter any string: Masterprograming
The input string is: Masterprograming

Pointers and arrays

Ham Example 4 me dikhte hai ki ham Arrays ko pointers mei kese istemal karte hai | ye program ham simple tarah se dekhte hai |

Example 4:

#include<stdio.h> 

int main() 
{ 
int arr[5] = { 1, 2, 3, 4, 5 }; 
int *ptr = arr; 

printf("%p\n", ptr); 
return 0; 
} 

Output:

0x7ffd4f212230

Aap Uper diye output ko dekh sakte hai isme hamne keval array ka address print karaya hai |

Pointer in c

Dosto mujhe ummed hai ki aap Pointer in c in hindi  ko acchi tarah se samanj gye honge agar aap ko ye post acchi lage to mere is website ko jarur follow kre or ha agar aap video bhi dekhna chahte hai to aap mere channel ko bhi subscribe kar sakte hai. channel ka link aapko home page par mil jayega |

Danish Ali

I Am a 1st Sem BCA Student & I have Skills C, C++ ,Python, HTML,CSS, Computer & Advance Hacking & Blogger & YouTuber.

Leave a Reply

Your email address will not be published. Required fields are marked *