Hello Community!
I was trying to optimize the task of initialize large arrays in C for my project on C64+. For example:
int largeArray[10] = {1, 1, 1, 1, 1,1, 1, 1, 1, 1}; // solution 1
I believe that "copy and paste" is not the better way to initialize the largeArray variable. Then I browse the Internet and found this solution (only works with GCC compiler)
int largArray[10] = { [0 ... 9] = 1}; // solution 2
Another solution(which will consume processing cycles from my app) is build a routine for initialize the array:
int largeArray[10]; // solution 3
for(int i=0;i<10;i++){
largeArray[i] = 1;
end
Then, there is a method similar to "solution 2" available in C compiler for C64+?
Thanks in advance.
By the way, for curiosity, in Python you can do the job in the most efficient way:
largeArray = [ 1 ] * 10