#include<stdio.h>
#include<string.h>intmain(){inta=10;char*string="Hello World";chars='H';doubled=23.98908;longl=343247891370492;// register b=10;// can't find the address of register variablesprintf("———————————————————————————————————————————");printf("\nProgram to find address of variables ");printf("\n———————————————————————————————————————————");printf("\nAddress of a | %p",&a);printf("\nAddress of string | %p",&string);printf("\nAddress of s | %p",&s);printf("\nAddress of d | %p",&d);printf("\nAddress of l | %p",&l);printf("\nmain address | %p",main);printf("\nmain address | %p",(void*)&main);printf("\n———————————————————————————————————————————\n");return0;}
Output
kodingwindow@kw:~$ gcc kw.c kodingwindow@kw:~$ ./a.out
———————————————————————————————————————————
Program to find address of variables
———————————————————————————————————————————
Address of a | 0x7fff701439cc
Address of string | 0x7fff701439d0
Address of s | 0x7fff701439cb
Address of d | 0x7fff701439d8
Address of l | 0x7fff701439e0
main address | 0x56238cd336fa
main address | 0x56238cd336fa
———————————————————————————————————————————
kodingwindow@kw:~$
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.