2 questions. How can I change the values of array1 passed to change_array in a more efficient manner? I tried the initializer list ( array_1 = {blah blah} but of course it didn't work. I was left with changing individual array values.
Second question I failed to learn earlier. If i initialize the counter variable in a for loop can I recycle it and use it again with out initializing. I get an error.
1. What do you mean by a more more efficient? If you want to set the fifth element of the array to 300 what you have is fine.
2. t is only in scope inside the loop. It doesn't exist outside the loop. That's why you can't use t in the second loop without declaring a new variable with that name.
1. more efficient may not have been the best selection of words. What if I want to set the
fifth through the twentieth elements of the array in the function? (assume the size of array is appropriate)
2.
t is only in scope inside the loop. It doesn't exist outside the loop. That's why you can't use t in the second loop without declaring a new variable with that name.
BUt there is no other less labor intensive way such as an initializer list to load different values fifth through the 20th e.g.? (short of a script to load data from memory to an array like pointer based)
Don't sweat it. Peter87's example probably translates into half a dozen instructions that take 30ns to run on a 3GHz processor. That's less time than it takes for the light bouncing off the car in front of you to reach your eye.
But what if I wanted to load values (e.g.16 elements ) into this array? I don't think it will take an initializer list in the fx? Or do I do every one by hand?