C: Print address of variable

2023-10-22

Print address of variable:

#include <stdio.h>
int
main (void)
{
  int i;
  printf ("i has address: %p\n", &i);
}

Compiling

Compile with:

cc main.c

Executing

Execute program with:

./a.out

Sample output

Output:

i has address: 0x7ffe6ac79df4

← Home