When I run this code in my Devcpp compiler ->
#include<bits/stdc++.h> using namespace std; int main() { vector<int> vec; for(int i=0;i<100000000;i++) vec.push_back(i); }
It works even at runtime. But when I launched β
#include<bits/stdc++.h> using namespace std; int arr[1000000000]; int main() { return 0; }
This gives me a communication error.
As long as space is required, both arr and vec require the same space. Then why does vec code work even fine at runtime, but arr code doesn't even compile.
c ++ arrays vector
user3522401
source share