萌新关于数组指针的一个问题
#include<stdio.h>int main()
{
int a = {
{{2014,1,0},{2014,2,0},{2014,3,0},{2014,4,0},{2014,5,0},{2014,6,0},{2014,7,0},{2014,8,31.3},{2014,9,35.5} ,{2014,10,58.7},{2014,11,49.6},{2014,12,55.5}
},
{
{2015,1,59.8},{2015,2,54.9},{2015,3,33.1},{2015,4,38.2},{2015,5,26.6},{2015,6,20.5},{2015,7,27.8},{2015,8,38.5},{2015,9,41.5} ,{2015,10,44.7},{2015,11,38.1},{2015,12,41.5}
},
{
{2016,1,34.9},{2016,2,36.4},{2016,3,47.5},{2016,4,37.9},{2016,5,30.6},{2016,6,23.4},{2016,7,26.6},{2016,8,34.3},{2016,9,0} ,{2014,10,0},{2014,11,0},{2014,12,0}
}
};
int (*p) = a;
return 0;
}
想问下大佬们指针p怎样才能指向{2014,1,0}这个数组的起始地址 非常感谢! int *p = a; 不知道是不是,以我理解数组是起始地址 这个多维数组看不懂{:10_250:} 本帖最后由 傻眼貓咪 于 2021-12-29 17:51 编辑
#include <stdio.h>
int main(){
/* 稍微作修改 */
float a =
{
{
{2014, 1, 0}, {2014, 2, 0}, {2014, 3, 0}, {2014, 4, 0}, {2014, 5, 0}, {2014, 6, 0},
{2014, 7, 0}, {2014, 8, 31.3}, {2014, 9, 35.5}, {2014, 10, 58.7}, {2014, 11, 49.6}, {2014, 12, 55.5}
},
{
{2015, 1, 59.8}, {2015, 2, 54.9}, {2015, 3, 33.1}, {2015, 4, 38.2}, {2015, 5, 26.6}, {2015, 6, 20.5},
{2015, 7, 27.8}, {2015, 8, 38.5}, {2015, 9, 41.5}, {2015, 10, 44.7}, {2015, 11, 38.1}, {2015, 12, 41.5}
},
{
{2016, 1, 34.9}, {2016, 2, 36.4}, {2016, 3, 47.5}, {2016, 4, 37.9}, {2016, 5, 30.6}, {2016, 6, 23.4},
{2016, 7, 26.6}, {2016, 8, 34.3}, {2016, 9, 0}, {2014, 10, 0}, {2014, 11, 0}, {2014, 12, 0}
}
};
float (*p) = &a;
printf("%.1f\n", ****p); // a
printf("%.1f", *(*(*(*p+1)+8)+2)); // a
return 0;
}2014.0
41.5 a327904410 发表于 2021-12-29 17:28
这个多维数组看不懂
我也被多维数组搞糊了{:5_99:} 傻眼貓咪 发表于 2021-12-29 17:49
谢谢您
页:
[1]