Is there a way to delay the array initialization. For example, instead of doing:
int array[2] = {1,2};
To do:
int array[2];
array = {1,2}; // possible to do with some sort of cast or other?
Is there a way to delay the array initialization. For example, instead of doing:
int array[2] = {1,2};
To do:
int array[2];
array = {1,2}; // possible to do with some sort of cast or other?
An array cannot be assigned to directly.
You would either need to assign each element individually, or use memcpy
along with a compound literal of the proper type.
memcpy(array, (int[2]){1,2}, sizeof(array));