preecher array, struct in C?

0

How do I fill leds and seq without needing a for loop?

int main()
{
    struct ledvalue
    {
        int seq[10]; 
        int leds[10]; 
    };


  struct ledvalue numbers;
  numbers.seq={0,1,2,3,4,5,6,7,8,9};
  numbers.leds={2,5,5,4,5,6,3,7,6,6};
}

I wanted to fill them in with the numbers because then I will need to compare inputs .

    
asked by anonymous 11.03.2017 / 01:40

1 answer

1

If the values are fixed, you can use a structure literal:

struct ledvalue numbers = {
    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
    { 2, 5, 5, 4, 5, 6, 3, 7, 6, 6 }
};

If they are not, it can not be: loop , even; or you can use memcpy() , but for vectors of that size, it probably makes use of a loop .

    
11.03.2017 / 01:51