In my code, I used pointer array like this.
arr = (int*)malloc(N * sizeof(int));
for (i = 0; i < N; i++)
scanf("%d", (arr + i));
Because pointer arithmetic points address.
But I wonder if it's right to only write (arr+i) without * or &.
What is right?
Please help me.
scanfarg needs to be anint *which is exactly what you have. Using*would be wrong as that would give anintand using&would be wrong as that would give anint **.aand indexi, the expression*(a + i)is exactly equal toa[i]. From that follows that&a[i]is equal to&*(a + i)which is equal toa + i. Which is exactly what you have.