Is there any way to assign values to a vector faster?

5

For example, I have the declaration of the following vector:

float vet[3] = {1, 1, 1};

I would like to change all values of the same one at a time, without having to change one by one element or create a new vector and assign to it:

vet[0] = -1;
vet[1] = 0;
vet[2] = 1;

Something like this:

vet = {-1, 0, 1};
    
asked by anonymous 10.11.2016 / 14:50

1 answer

3

Directly you have no. You could create a function where you pass the parameters and it assigns each element. But this is the opposite of being faster, at most it gets shorter.

This is generally against the basic philosophy of C, although nothing prevents it from being used if it is appropriate.

    
10.11.2016 / 14:54