Say I've got an array that contains 100 elements. Same array only has elements 0 through 69 filled because that's all the data that was captured and 70 through 99 are zeros.
Before the data in the array is transferred, a start of message must be added to the beginning and has to be inserted after gathering the data.
To insert the data, you use a for loop to manually shift the array elements to the right by n (see the code below).
uint8_t foo[100];
/*
* Some code that puts data in the first 70 elements
*/
//Need to insert the start of message
for(i=99; i>0; i--)
{
foo[i+1] = foo[i];
}
On the first run of that for loop, it makes foo[100] = foo[99]. Is that a valid operation or does foo[100] just go off into never never land? I know in languages like MATLAB, it will dynamically resize your array, but does C do the same thing?