how to convert n space separated integers in c++

C++
int i, n, arr[100];

scanf("%d", &n);
for (i = 0; i < n; ++i)
    scanf("%d", &arr[i]);

Source

Also in C++: