实例 C 语言创建指针变量

x
 
#include <stdio.h>
int main() {
  int myAge = 43;  // An int variable
  int* ptr = &myAge;  // A pointer variable, with the name ptr, that stores the address of myAge
  // Output the value of myAge (43)
  printf("%d\n", myAge);
  // Output the memory address of myAge (0x7ffe5367e044)
  printf("%p\n", &myAge);
  // Output the memory address of myAge with the pointer (0x7ffe5367e044)
  printf("%p\n", ptr);
  return 0;
}
                    

输出结果

43
0x7ffe5367e044
0x7ffe5367e044