Simple Program for Print address of Variable Using Pointer in C
Pointers (pointer variables) are special variables that are used to store addresses rather than values.
To print the address of a variable we use %p
#include <stdio.h>
#include<conio.h>
void main()
{
int num = 10;
printf("Value of variable num is: %d", num);
/* To print the address of a variable we use %p
* format specifier and ampersand (&) sign just
* before the variable name like &num.
*/
printf("\nAddress of variable num is: %p", &num);
getch();
}
No comments:
Post a Comment
for more information please share like comment and subscribe