I am really new to C, so I am sorry if this is a absolute beginner question, but I am getting a segmentation error when I am building large array, relevant bits of what I am doing is:
unsigned long long ust_limit;
unsigned long long arr_size;
/* ust_limit gets value around here ... */
arr_size = ((ust_limit + 1) / 2) - 1;
unsigned long long numbs[(int)arr_size];
This works for some values of ust_limit, but when it gets above approximately 4.000.000 a segmentation fault occurs. What I want is to detect a possible segfault and fail gracefully. How can I know which values would cause a segmentation fault. And, is this something platform dependant?