float bases[7];
if (level < 2) {
bases = {80, 70, 50, 20, 10, 2 , 1};
}else{
bases = {100, 100, 80, 50, 25, 6, 3};
}
这是无效的。但那么,做到这一点的正确方法是什么?
答案 0 :(得分:1)
您可以尝试只是逐个元素地复制数据,或者使用:
float bases[7];
static float *bases1 = {80,70,50,20,10,2,1};
static float *bases2 = {100,100,80,50,25,6,3};
if (level < 2)
memcpy (bases, bases1, sizeof(bases));
else
memcpy (bases, bases2, sizeof(bases));