#include<stdio.h>intmain(){double a[]={1000.0,2.0,3.4,17.0,50.0};double* p[5];// 把 p 声明为一个数组,由 5 个double 指针组成。// 因此,p 中的每个元素,都是一个指向 double 值的指针。int i;for(i =0; i <5; i++){
p[i]=&a[i];printf("p[%d] = %f\n", i,*p[i]);}for(i =0; i <5; i++){printf("a[%d] = %f\n", i, a[i]);}return0;}
运行结果
实例2
#include<stdio.h>constint MAX =4;intmain(){constchar* names[]={"Zara Ali","Hina Ali","Nuha Ali","Sara Ali",};int i =0;for(i =0; i < MAX; i++){printf("Value of names[%d] = %s\n", i, names[i]);}for(i =0; i < MAX; i++){printf("Value of names[%d] = %s\n", i,*(names+i));}return0;}