Search Results

Search found 1 results on 1 pages for 'guygreer'.

Page 1/1 | 1 

  • Programmatically find maximum static array size in C++

    - by GuyGreer
    I am curious whether it is possible to determine the maximum size that an array can have in C++. #include <iostream> using namespace std; #define MAX 2000000 int main() { long array[MAX]; cout << "Message" << endl; return 0; } This compiles just fine, but then segfaults as soon as I run it (even though array isn't actually referenced). I know it's the array size too because if I change it to 1000000 it runs just fine. So, is there some define somewhere or some way of having #define MAX MAX_ALLOWED_ARRAY_SIZE_FOR_MY_MACHINE_DEFINED_SOMEWHERE_FOR_ME? I don't actually need this for anything, this question is for curiosity's sake.

    Read the article

1