Dynamic memory allocation?
Hello, My program basically reads a binary file and stores it in an array. The program work's while the size of my array is small. But the file I am working is very large and hence the compiler just stops working due to the runtime issue. My lead to this problem is to allocate dynamic memory to my array. But I have only seen dynamic memory being allocated to local variables. Is there a method I could apply dynamic memory to my numbers[] array itself? This could fix my problem. Any thoughts? #include <iostream> #include <fstream> using namespace std; int main() { int size; fstream file; file.open("this.bin", ios::binary | ios::in |ios::ate); size = file.tellg(); size = size/4; int numbers[size]; file.seekg(0, ios::beg); file.read(reinterpret_cast<char *>(numbers), sizeof(numbers)); for(int i=0; i<size; i++){ cout << numbers[i]; } file.close(); file.close(); return 0; }