What is Pointer ?
Pointer is a address variable that hold the address of another variable.The * (indirection or dereference operator), that gives the contents of an object that pointed to by a pointer.
To declare a pointer to a variable:
data_type_name * variable nameint *ptr;
Example 1:
void main( ){int a = 10 ;printf ( "\nAddress of a = %u", &a );printf ( "\nValue of a = %d", a );}
Output:
address of a=1565
value of a=10
Example 2:
void main(){int a = 5 ;printf ( "\nAddress of a = %u", &a );printf ( "\nValue of a = %d", a ) ;printf ( "\nValue of a = %d", *( &a ) );}
Output:
Address of a = 1444
Value of a = 5
Value of a = 5
Comments
Post a Comment