0

I have defined 6 arrays, and each array can contain 10 values:

static s16 arr_A[10];
static s16 arr_B[10];
static s16 arr_C[10];
static s16 arr_D[10];
static s16 arr_E[10];
static s16 arr_F[10];

Now I have an existing function which gives me values of interest:

FunctionContainsValuesOfInterest(&adc_values[0]);

myValues = adc_values[GROUP_A];
myValues = adc_values[GROUP_B];
myValues = adc_values[GROUP_C];
myValues = adc_values[GROUP_D];
myValues = adc_values[GROUP_E];
myValues = adc_values[GROUP_F];

At each call of FunctionContainsValuesOfInterest() I get new values. Now I would like to create a loop where I fill for example the array arr_A[] wih 10 values of adc_values[GROUP_A], arr_B[] with 10 values of adc_values[GROUP_B].

What is here the best and most efective procedure?

1
  • 2
    Types are missing, so cannot suggest anything. Commented Nov 2, 2017 at 13:54

1 Answer 1

1

Assuming that the type of adc_values element is the same as that of arr_Xs, i.e. s16, you can use memcpy function to copy whole or a portion of adc_values:

memcpy(arr_A, &adc_values[GROUP_A], sizeof(arr_A));

The assumption above is that adc_values[GROUP_A] is that ten consecutive items at adc_values[GROUP_A+i] for i between 0 and 9, inclusive, are the values that need to be copied into arr_A.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.