•File has the following layout:
• DWORD: number of elements
• DWORD[]: an array of integers
•
•File: 2,
0, 1
•File: 10,
0, 1, 0, 1 , 0, 2, 2, 2, 2, 2
•File:
0
•
•//
C/C++
•int
*data;
•int
numElements;
•
•void
ReadData()
•{
• free(data); // NULL can be passed
•
• ReadFile(…, &numElements,
sizeof(numElements), …);
• data = (int *)malloc(numElements);
// you can pass 0 here, needs a cast in C++
•
• if (data)
• {
• ReadFile(…, data,
numElements*sizeof(data[0]), …);
• }
•}
•