I'm afraid that initializer syntax you are trying to use is only possible for variable declarations.
Possible solution are to declare a new array and copy it using memcpy
#include <iostream>
#include <cstring>
int main()
{
unsigned char arr[4] = {0x0F, 0x0F, 0x0F, 0x0F};
if (elsecondition){
unsigned char arr1[4] = {0xFF, 0xFF, 0xFF, 0xFF};
memcpy(arr, arr1, sizeof(arr));
}
return 0;
}
or to do the assignment one element at a time
#include <iostream>
int main()
{
unsigned char arr[4] = {0x0F, 0x0F, 0x0F, 0x0F};
if (elsecondition){
// we can use a loop, since all values are identical
for (int i = 0; i < sizeof(arr); ++i)
arr[i] = 0xFF;
}
return 0;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…