Use a pointer on the right-hand side of an assignment statement to assign its value to another pointer. - C Pointer

C examples for Pointer:Pointer Variable

Description

Use a pointer on the right-hand side of an assignment statement to assign its value to another pointer.

Demo Code

#include <stdio.h>

int main(void)
{
   int x = 99;/*from   w  w w  . j  av a2 s.c  o  m*/
   int *p1, *p2;

   p1 = &x;
   p2 = p1;

   /* print the value of x twice */
   printf("Values at p1 and p2: %d % d\n", *p1, *p2);

   /* print the address of x twice */
   printf("Addresses pointed to by p1 and p2: %p %p", p1, p2);

   return 0;
}

Result


Related Tutorials