// here I manipulate a Can bus.
So I would like to recuperate 9 variable , but for each iteration i get only one variable .
I want to assign this variable to another out of the for loop .
}
Is my question clear for you ?
Here we have three integer variables too: int data[3];
They have been aggregated as array.
You can still address the individual integers:
1 2 3
data[0]
data[1]
data[2]
Now the loop:
1 2 3
for ( int i = 0; i < 3; ++i ) {
data[i] = (i+1) * 10;
}
* On first iteration the i==0, and therefore a value is written only to data[0]. The value is (i+1)*10, i.e. (0+1)*10. 10
* On second iteration the i==1, and therefore a value is written only to data[1]. The value is (i+1)*10, i.e. (1+1)*10. 20
The int& var1 {data[0]}; creates a reference. Reference is an alias, an another name for existing variable. Here the variable is data[0] and the name of reference is var1.