Why do I get bad_alloc error?
It appears to be limiting me to 32 bits but it is a 64 bit machine and compiler. I am using this to store large sets of data which are in the vector int array. I tried setting heap and stack during compiling but this did not seem to affect the bad_alloc.
#include<iostream>
#include<vector>
//set vector with large array of integers
struct Fld
{
int array[256];
};
std::vector <Fld> fld;
int main()
{
std::cout << fld.max_size() << "\n";
int length = 100000000;
try
{
//show maximum vector array size
std::cout << fld.max_size() << "\n";
std::cout << "resize [" << length << "]\n";
//resize to size larger than 32 bit
fld.resize(length);
std::cout << "good\n";
}
catch(std::bad_alloc& ba)
{
std::cout << "bad_alloc caught: " << ba.what() << "\n";
}
}