So value 1,2,3,4,5 should be put in new_buffer[0] and 6,7,8,9,10 into new_buffer[1], and so on.
My buffer array contains 400 values if this makes any difference.
I hope i explained it somewhat understandable, would greatly appreciate help on this.
Best Regards
Lasse
So, the 0, 5, 10, 15, etc. elements of the incoming array go into position 0 of a different array.
The 1, 6, 11, 16, etc. elements go into position 1 of a different array.
The 2, 7, 12, 17, etc. elements go into position 2 of a different array.
See a pattern?
A for loop running from 0 to 400/5, with 80 statements in it would work.
However, splitting 400 elements into 80 arrays makes little sense.
Learning to index a single array as though it was a 2D array would make more sense.
What i mean is that the first 5 elements of the buffer array should be put in new_buffer[0] and the next 5 elements of the buffer array should be put in new_buffer[1] and so on, the buffer array contains about 400 elements so the last 5 elements in the buffer array would be put in something like new_buffer[80]. Or maybe i just misunderstood you? and not the other way around.
Thanks for your reply however
What i mean is that the first 5 elements of the buffer array should be put in new_buffer[0] and the next 5 elements of the buffer array should be put in new_buffer[1] and so on
You want to put 5 elements from one array into one element of another array? Unless new_buffer is a 2D array, you can't. If it is, the the elements of buffer[0] to buffer[4] go into new_buffer[0][0] to new_buffer[0][4].
But, I still fail to see the need to copy the arrays. With proper indexing a 1D array can be accessed as though it was a 2D array. After all, the 2D array is actual stored in memory as a sequence of memory locations, just like a 1D array. A little arithmetic goes on behind the scenes to compute an offset from the start of the array to find element [r].
Thanks for your reply!
yea you are probably right that there's a better way to do it.
What im trying to do is take my buffer array that is filled with binary values and convert it to numbers. buffer[0][4] is equal to one number and buffer[5][9] equal to another, maybe you could help me with the code? i i would greatly appreciate it. this is what i got so far: