What is the easiest way to read space separated input into an array? 

```
//input:5
        1 2 3 4 7

int main() {
    int n;
    cin>>n;
    int array[n];
    for (int i =0;i<n;i++){
        cin>>array[i];
    }
    cout<<array; 
    return 0;
}  

```

I tried the code above but the output is 0x7ffe42b757b0.