Possible Duplicate:
Stack overflow visual C++, potentially array size?
This code is simply meant to read values from a binary file into the array DataBuffer. When the size of DataBuffer is greater than or equal to 515000, it simply crashes. I am developing this in Visual C++ 2010 on Windows 7. The function cbFileRead() is something whose source code I can not access. cbFileRead() expects DataBuffer to be of the type USHORT*.
#include <stdio.h> // printf()
#include "cbw.h" // cbFileRead()
int main(int argc, char* argv[]) {
// Declarations
char* FileName = argv[1];
long FirstPoint = 0;
long NumPoints;
// Set data collection sizes
const long chunkSize = 515000;
NumPoints = chunkSize; // Number of points to be read into mem
WORD DataBuffer[chunkSize-1];
// Get data
cbFileRead(FileName, FirstPoint, &NumPoints, DataBuffer);
printf("Completed on data point %d whose value is %d\n", NumPoints, DataBuffer[chunkSize-1]);
return 0;
}
What reasons are there for this crashing? I would expect the array size to be able to go much higher.
std::vectorinstead