preecher array, struct in C?

Asked

Viewed 99 times

0

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

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 with the numbers because then I’ll need to compare inputs.

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’re not, there’s no way loop, same; or you can use memcpy(), but for vectors this size, she probably makes use of a loop.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.