new int(len)
allocates a single int
object and initialises it with the value len
. On the other hand, new int[len]
allocates an array of int
s of length len
.
Compare with int x(5);
and int x[5];
.
When you were allocating only a single int
, cin>>*(vect+i);
was attempting to write to objects that have not been allocated.