Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Friday, February 18, 2011

C23 : Print current and next memory address of a variable

Back to Home   &  C


//Print current and next memory address of a variable

#include<stdio.h>
#include<conio.h>
void main()
{
int a,*p;
clrscr();
printf("Enter a number\n");
scanf("%d",&a);
p=&a;
printf("Value in variable a=%d\n",a);
printf("Address of variable a=%u\n",p);
p=p+1;
printf("NEXT MEMORY ADDRESS OF A=%u",p);
getch();
}
-------------------------------------------------------------------
Output
Enter a number
12
Value in variable a=12
Address of variable a=65524
NEXT MEMORY ADDRESS OF A=65526
===============================================
Back to Home   &  C