I was working on a project for my university and I discovered something strange.
The declaration of an array of N elements (of type long long int), where N is input from the user, throws segmentation fault for large numbers. On the contrary, the declaration of a vector of the same number works like a charm.
Declarations:
vector<long long int> A(N);
versus
long long int A[N];
I assume there is a difference in the way the information is stored in the memory, but correct me if I am wrong, I think that both arrays and vectors store their elements sequentially in order to achieve O(1) access to their elements. So what's the real difference between the two and what causes the segmentation fault?