我正在尝试编译并将每个值的地址显示到数组中。
int i[10] = {1,2,3,4,5,6,7,8,9,10}, x;
float f[10] = {1,2,3,4,5,6,7,8,9,10};
double d[10] = {1,2,3,4,5,6,7,8,9,10};
/*int *p_i = &i;
float *p_f = &f;
double *p_d = &d;*/
int main(void){
printf("\n\tInteger\tFloat\tDouble");
printf("\n=======================================");
/* loop to show the address in each element that have the arrayes */
for(x = 0; x < 10; x++){
printf("\nElement %d\t%d\t%d\t%d", x+1, &i[x], &f[x], &d[x]);
// printf("\nElement %d\t%d\t%d\t%d", x+1, p_i++, p_f++, p_d++);
}
printf("\n=======================================\n");
}
我不明白为什么语法正确。我也有搜索,找到的代码几乎是一样的。