Printing Pointer Variable Contents - C Pointer

C examples for Pointer:Pointer Variable

Introduction

Print the memory address of pointers and non-pointer variables using the %p conversion specifier.

The following code uses the %p conversion specifier to print the memory address for the pointer and integer variable.

Demo Code

#include <stdio.h> 
int main()//from   w  w  w  .  java  2 s .  c om
{ 
   int x = 1; 
   int *iPtr; 

   iPtr = &x; 
   *iPtr = 5; 
   printf("\n*iPtr = %p\n&x = %p\n", iPtr, &x); 
}

Result


Related Tutorials