mardi 13 août 2019

How to initialize a very long array in c++

I am just trying to initialize an huge array. My code is given below:

#include<iostream>
using namespace std;

int main(){
    int T;
    cin>>T;
    while(T--){
        int d;
        cin>>d;
        int arr[d+1];
        for(int i=0; i<=d; i++)
            arr[i]=0;
    }
    return 0;
}

Now when I input

1 502334160

then i got error Runtime Error - SIGSEGV. I want to know how to initialize this type of array;

Aucun commentaire:

Enregistrer un commentaire