What are Pointers in C
It is a variable which is used to store the address of another variable in other words you can ay it points to the address of the variable. pointers improve the performance of the program also helps to reduce the code and can accessed to any memory location , Pointers can be used with array, functions and structures .
Example pointer
[php]#include<stdio.h>
#include<conio.h>
void main()
{
int a=70 ;
int *p; // pinter declaration;
p=&amp;a;//store the address of a
printf("%x",p);// address of pointer
getch();
}[/php]
Output
fff4
Pointers concept and description
Sr.No. | Concept & Description |
---|---|
1 | Pointer arithmeticThere are four arithmetic operators that can be used in pointers: ++, –, +, – |
2 | Array of pointersYou can define arrays to hold a number of pointers. |
3 | Pointer to pointerC allows you to have pointer on a pointer and so on. |
4 | Passing pointers to functions in CPassing an argument by reference or by address enable the passed argument to be changed in the calling function by the called function. |
5 | Return pointer from functions in CC allows a function to return a pointer to the local variable, static variable, and dynamically allocated memory as well. |
No comments:
Post a Comment