创建一个指针数组,每个指针元素都初始化为指向数组初始化内容的地址,例如:
int *ip[2] = {xp, &g};
ip[0] = &xp, ip[1] = &(&g).
指针数组和指针的概念很容易混淆。下面两个代码一个可以运行,一个运行失败。

#include <stdio.h>
#include <conio.h>
int main()
{
    int g = 15;
    int *ip[1] = {&g};
     
	printf("ip = %p, *ip = %d, **ip = %d\n",ip, *ip, **ip);
    getchar();
    return 0;
}
 
#include <stdio.h>
#include <conio.h>
int main()
{
    int g = 15;
    int *ip = &g;
     
	printf("ip = %p, *ip = %d, **ip = %d\n",ip, *ip, **ip);
    getchar();
    return 0;
}

相关文章:

  • 2021-11-19
猜你喜欢
  • 2021-05-23
  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2020-03-21
相关资源
相似解决方案