Getting segmentation fault for below code

#include
using namespace std;

int main(){

long long int n;
cin >> n;
int a[1000000000000000];
int i = 0;
while(n > 0){
    int m = n%10;
    if (m > 4 && n > 9)
    {
        m = 9 - m;
    }
    a[i] = m;
    i++;

}
for(int k = 0; k < i-2; i++){
    cout << a[i];
}

return 0;

}

@simmy_gupta0404 you cannot make such a big array. Anyhow if there are 19 digits in the number you need 19 size at max for the array, not 10^18 itself.