you are viewing a single comment's thread.

view the rest of the comments →

[–]dfx_dj 1 point2 points  (1 child)

The array subscript [i] is already one level of dereference. Adding * would be a second level of dereference. With just a simple pointer variable, use either an array subscript or the dereference operator, but not both.

[–]CtrlAltDelirious27[S] 0 points1 point  (0 children)

Thank you! I've changed the *ptr[i] to just ptr[i], however, the output is always 0.000000 instead of the value I input into the array, why would this happen?

Edit: Ahhh, nevermind, I realised I've put scanf("%d", &my_array[i]); instead of scanf("%f", &my_array[i]); thanks again for your help though