C语言二维数组的一点疑问!const float rain[YEARS][MONTHS]={4.3,4.3,4.3,3.0,2.0,1.2,0.2,0.2,0.4,2.4,3.5,6.6,8.5,8.2,1.2,1.6,2.4,0.0,5.2,0.9,0.3,0.9,1.4,7.3,9.1,8.5,6.7,4.3,2.1,0.8,0.2,0.2,1.1,2.3,6.1,8.4,7.2,9.9,8.4,3.3,1.2,0.8,0.4,0.0,0.6,1.
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/22 22:55:42
C语言二维数组的一点疑问!const float rain[YEARS][MONTHS]={4.3,4.3,4.3,3.0,2.0,1.2,0.2,0.2,0.4,2.4,3.5,6.6,8.5,8.2,1.2,1.6,2.4,0.0,5.2,0.9,0.3,0.9,1.4,7.3,9.1,8.5,6.7,4.3,2.1,0.8,0.2,0.2,1.1,2.3,6.1,8.4,7.2,9.9,8.4,3.3,1.2,0.8,0.4,0.0,0.6,1.
C语言二维数组的一点疑问!
const float rain[YEARS][MONTHS]={
4.3,4.3,4.3,3.0,2.0,1.2,0.2,0.2,0.4,2.4,3.5,6.6,
8.5,8.2,1.2,1.6,2.4,0.0,5.2,0.9,0.3,0.9,1.4,7.3,
9.1,8.5,6.7,4.3,2.1,0.8,0.2,0.2,1.1,2.3,6.1,8.4,
7.2,9.9,8.4,3.3,1.2,0.8,0.4,0.0,0.6,1.7,4.3,6.2,
7.6,5.6,3.8,2.8,3.8,0.2,0.0,0.0,0.0,1.3,2.6,5.2,
};
定义了一个二维数组,定义为float类型,按照C语言的语法,数组最后一个元素5.2后面
不需要逗号的,但是在VC++上编译时,弹出50个警告信息.当我把5.2后面的“,”添加上去后,警告全部消失!这种现象的原因是什么?
C语言二维数组的一点疑问!const float rain[YEARS][MONTHS]={4.3,4.3,4.3,3.0,2.0,1.2,0.2,0.2,0.4,2.4,3.5,6.6,8.5,8.2,1.2,1.6,2.4,0.0,5.2,0.9,0.3,0.9,1.4,7.3,9.1,8.5,6.7,4.3,2.1,0.8,0.2,0.2,1.1,2.3,6.1,8.4,7.2,9.9,8.4,3.3,1.2,0.8,0.4,0.0,0.6,1.
这个与那个逗号没有任何的关系.
只是你的数字系统默认是double型的.分配了比较长的内存,
但是你却定义的是const float 的类型,必须裁减,所以警告.
你要是修改成const double.一定不会有警告.