carrayslistprecompiler

how can I autoamate variable input array lists


I need to call a series of functions that require a list in an input array as following:

1st call to func:
custom_type_t inarray = {1,2,3,4,5,6,7,8,9,10};
2nd call to func:
custom_type_t inarray = {11,12,13,14,15,16,17,18,19,20};
...

How can I pack this into a function that I can call with a particular argument, that will extract the numbers and populate the array accordingly? Should I use the precompiler accordingly? Thanks for any ideas!


Solution

  • for(int i = 1; i < 11; i++) inarray[i - 1] = i;
    
    for(int i = 11; i < 21; i++) inarray[i - 11] = i;