Different Pointer Operator in C Programming

January 7, 2012 No Comments » Hits : 218





Pointer Operator in C Program

  1. To Create Pointer to a variable we use ‘*’ , ‘&’ Operator [ we have nothing to do with multiplication and Logical AND Here ]
  2. ‘&’ operator is called as address Operator
  3. ‘*’ is called as ‘Value at address’ Operator
  4. Value at address’ Operator gives ‘Value stored at Particular address.
  5. ‘Value at address’ is also called as ‘Indirection Operator’

Program :

#include<stdio.h>

int main()
{
int n = 20;
printf("\nThe address of n is %u",&n);
printf("\nThe Value of n is %d",&n);
printf("\nThe Value of n is %d",*(&n));
}

Output:

The address of n is 1002
The Value of n is 20
The Value of n is 20

How *(&n) is same as printing the value of n ?

  1. &n gives address of the memory location whose name is ‘n’.
  2. ‘ * ‘  means value at Operator gives value at address specified by &n.
  3. m = &n : Address of n is stored in m , but remember that m is not ordinary variable like n
  4. So Ccompiler must provide space for it in memory

What does this declaration [ int *m ; ] tells compiler ?

  1. m is declared as  that m will be used only for storing the address of the integer valued variables
  2. We can also say that m points to integer
  3. Value at the address contained in m is integer .

    Declaration
What it tells ?Memory Required 
 1
int *pp is going to store address of integer value2 bytes
2
float *qq is going to store address of floating value2 bytes
3char *chch is going to store address of character variable2 bytes

Incoming search terms: