print variable adress c
The address of a variable in C can be printed using the ampersand operator (&). Here is an example:
#include <stdio.h>
int main() {
int num = 10;
printf("The address of num is: %p", &num);
return 0;
}
This code declares an integer variable num
and then uses the printf
function to print its address using the %p
format specifier. The ampersand operator &
is used to get the address of the variable.
When you run this code, it will output the memory address of the variable num
.