Preparing the Array Buffer with Data
Go Up to Writing Data to an Array
Create an array buffer to hold the data to be written to the array. Make it large enough to hold all the elements in the slice to be written (which could be the entire array). For example, the following declares an array buffer large enough to hold 4 long elements:
- 1. Create a variable specifying the length of the array buffer:
short len; len = sizeof(hcnt);
- 2. Fill the array buffer with the data to be written.
- If you are creating a new array, then fill the buffer with data. For
hcnt = 4; hcnt = 5; hcnt = 6; hcnt = 6;
- To modify existing array data instead of creating a new one, then perform all the steps listed in Reading Data from an Array to read the existing array data into the array buffer. Modify the data in the buffer.