Pointer in C language
Pointer is a special type of variable present in 'C' language, which stores memory address of a variable as its value. Pointer must occupy two bytes in computer memory. Pointer stores unsigned integer value only, which are accessed by %u formatted string. Updation (increment/ decrement) of pointer is according to its datatype.
เคธी เคฒैंเค्เคตेเค เคฎें เคชॉเคंเคเคฐ เคเค เคตिเคถेเคท เคช्เคฐเคाเคฐ เคा เคตेเคฐिเคเคฌเคฒ เคนोเคคा เคนै เคो เคเคธी เคช्เคฐเคाเคฐ เคे เคिเคธी เคฆुเคธเคฐे เคตेเคฐिเคเคฌเคฒ เคा เคฎेเคฎोเคฐी เคเคก्เคฐेเคธ (เคตैเคฒ्เคฏू เคे เคฐूเคช เคฎें) เคฐเคเคคा เคนै। เคชॉเคंเคเคฐ เคธเคฆैเคต เคฎेเคฎोเคฐी เคฎें เคฆो เคฌाเคเค เค्เคฐเคนเคฃ เคเคฐเคคे เคนै। เคชॉเคंเคเคฐ เคेเคตเคฒ เค
เคจเคธाเคंเคก เคเคจ्เคिเคเคฐ เคตैเคฒ्เคฏू เคธ्เคोเคฐ เคเคฐเคคे เคนै เคिเคธे %u เคซॉเคฐเคฎेเคेเคก เคธ्เค्เคฐींเค เคธे เคเค्เคธेเคธ เคिเคฏा เคाเคคा เคนै। เคชॉเคंเคเคฐ เคा เค
เคชเคกेเคถเคจ เคเคธเคे เคกाเคा เคाเคเคช เคे เค
เคจुเคธाเคฐ เคนोเคคा เคนै।
Declaration of pointer:-
Syntax:-
data _ type * pointer _ name;
Example:-
char *p;
int *link;
float *ptr;
double *a;
Initialization of pointer:-
Providing initial value to a pointer variable at the time of its declaration is called initialization of pointer.
เคชॉเคंเคเคฐ เคो เคช्เคฐाเคฐंเคญिเค เคฎाเคจ เคช्เคฐเคฆाเคจ เคเคฐเคจा เคเคจिเคถिเคฏเคฒाเคเคेเคถเคจ เคเคนเคฒाเคคा เคนै।
Syntax:-
datatype *pointer _ name= &variable _ name;
Example:- 1. float *ptr=&a;
2. float *ptr, x=10, y=25;
ptr=&x;
printf ("x=%f",*ptr);
ptr=&y;
printf ("y=%f",*ptr);
Advantages of pointer:-
1.) Use of pointers increases speed of execution of a C program.
2.) Pointer can able to access user defined data types like array, union, string, structure, function, file etc with normal data type as well.
3.) Function uses pointer in call by reference method.
4.) User can perform dynamic memory allocation through pointers.
5.) Pointer can able to change value of actual argument passed to a function.
เคชॉเคंเคเคฐ เคे เคฒाเคญ-
1.) เคชॉเคंเคเคฐ เคे เคช्เคฐเคฏोเค เคธे เคธी เคช्เคฐोเค्เคฐाเคฎ เคा เคเค्เคธीเค्เคฏूเคถเคจ เคคीเคต्เคฐ เคนोเคคा เคนै।
2.) เคชॉเคंเคเคฐ เคे เคฆ्เคตाเคฐा เคธाเคฎाเคจ्เคฏ เคกाเคा เคाเคเคช เคे เคธाเคฅ เคธाเคฅ เคฏूเคเคฐ เคกिเคซाเคंเคก เคกाเคा เคाเคเคช เคैเคธे เค
เคฐे,เคธ्เค्เคฐींเค,เคธ्เค्เคฐเค्เคเคฐ,เคฏूเคจिเคฏเคจ เคเคค्เคฏाเคฆि เคो เคญी เคเค्เคธेเคธ เคिเคฏा เคा เคธเคเคคा เคนै।
3.) เคซंเค्เคถเคจ เคी เคॉเคฒ เคฌाเคฏ เคฐिเคซเคฐेเคจ्เคธ เคฎेเคฅเคก เคฎें เคชॉเคंเคเคฐ เคा เคช्เคฐเคฏोเค เคिเคฏा เคाเคคा เคนै।
4.) เคชॉเคंเคเคฐ เคे เคฆ्เคตाเคฐा เคฏूเคเคฐ เคกाเคฏเคจाเคฎिเค เคฎेเคฎोเคฐी เคเคฒोเคेเคถเคจ เคเคฐ เคธเคเคคा เคนै।
5.) เคชॉเคंเคเคฐ เคे เคฆ्เคตाเคฐा เคซंเค्เคถเคจ เคे เคเค्เคुเค
เคฒ เคเคฐ्เคुเคฎेंเค เคी เคตैเคฒ्เคฏू เคो เคชเคฐिเคตเคฐ्เคคिเคค เคिเคฏा เคा เคธเคเคคा เคนै।
Disadvantages of pointer:-
1.) If pointer variable will update with incorrect memory address, then it will affect other programs.
2.) It is a responsibility of a programmer to free allocated blocks after program execution through pointer, if it was not done then computer system faces memory overflow.
เคชॉเคंเคเคฐ เคी เคนाเคจिเคฏाँ -
1.) เคฏเคฆि เคชॉเคंเคเคฐ เคो เคเคฒเคค เคฎेเคฎोเคฐी เคเคก्เคฐेเคธ เคे เคธाเคฅ เค
เคชเคกेเค เคिเคฏा เคाเคคा เคนै เคคเคฌ เคฏเคน เค
เคจ्เคฏ เคช्เคฐोเค्เคฐाเคฎ เคो เคนाเคจी เคชंเคนुเคा เคธเคเคคा เคนै।
2.) เคฏเคน เคช्เคฐोเค्เคฐाเคฎเคฐ เคी เคिเคฎ्เคฎेเคฆाเคฐी เคนै เคि เคตเคน เคชॉเคंเคเคฐ เคฆ्เคตाเคฐा เคช्เคฐเคฆเคค्เคค เคฎेเคฎोเคฐी เคो เคाเคฎ เคนो เคाเคจे เคे เคชเคถ्เคाเคค เคซ्เคฐी เคเคฐे เค
เคจ्เคฏเคฅा เคเคตเคฐเคซ्เคฒो เคंเคกीเคถเคจ เคเคค्เคชเคจ्เคจ เคนो เคธเคเคคी เคนै।
Comments
Post a Comment