I have an array static const unsigned int numbers[] = {1, 2, 3, 4, 5};
From an another loop I am getting integers, how do I fill my array numbers[]
with those incoming integers instead?
I have an array static const unsigned int numbers[] = {1, 2, 3, 4, 5};
From an another loop I am getting integers, how do I fill my array numbers[]
with those incoming integers instead?
As you guessed, the "static" part limits it's scope to that compilation unit. It also provides for static initialization. "const" just tells the compiler to not let anybody modify it. This variable is either put in the data or bss segment depending on the architecture, and might be in memory marked read-only.
More info there
First of all, I never seen assign an array in this way:
numbers[] = test;
Maybe you should study about array. Maybe you can use this way for copy:
int array [] = {1,3,34,5,6};
int newarr [] = {34,2,4,5,6};
std::copy(newarr, newarr + 5, array);
or just use simple loop:
for (int i = 0; i < arrayLength; i++) {
array[i] = newValue[i];
}
For more read here
Moreover you declare your array as const
that stay for constant, tells you something?
[...]constants are useful for parameters which are used in the program but are do not need to be changed after the program is compiled.
So I suggest to sudy about const
too! Read here