How can i repeat assignment value to different types of datas?

Viewed 48

I have data list of different data types.

Datas are like this.

data1 : uint8

data2 : int16

data3 : float32 …

And I want to assignment value to datas as below.

data1 = 10;
data2 = -40;
data3 = 273.2;
…

Because there are many datas, I want to repeat aggignment work more conveniently somewhat like using for loop.

How can I do this?

1 Answers

To aggregate your data in a struct:

struct example {
    uint8 data1;
    int16 data2;
    float32 data3;
} d = { 10, -40, 273.2 };

d = (struct example) {5, 19, 27.1};
Related