Write a C program to print address of a variable.
int main() {
int data;
/* get the input from the user */
printf("Enter value for data:");
scanf("%d", &data);
printf("Value of data: %d\n", data);
/* print the address of the variable */
printf("Address of data: 0x%x\n", (int)&data);
return 0;
}
Output:
jp@jp-VirtualBox:~/$ ./a.out
Enter value for data:100
Value of data: 100
Address of data: 0xbf995a5c
Enter value for data:100
Value of data: 100
Address of data: 0xbf995a5c
No comments:
Post a Comment