Pointer reuse in C.

 

01  #include<stdio.h>
02
03 int main()
04 {
05 int x=10,y=20; //integer variables
06
07 int *ptr; //integer pointer
08
09 ptr= &x; // ptr points to 'x'
10
11 printf("Value of X : %d n",*ptr);
12
13 ptr=&y; //now ptr points to 'y'
14
15 printf("Value of Y : %d n",*ptr);
16
17 return 0;
18 }
 
 
OUTPUT :

Value of X : 10
Value of Y : 20

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.