If I want to create a vector of size components and I want all components to be 1, one way to do this is, of course, to use a for loop in this way
#include <stdio.h>
int main()
{
int size=100;
int array[size];
for(int j=0; j<size; j++)
{
array[j]=1;
}
}
But it doesn't look like the way programmers would do it. How can I do this vectorially, that is, without changing one element at a time?
memsetto set the individual bytes (not elements). But no matter what you do, ultimately there will always be a loop somewhere, even if it's not explicitly in your own code.