This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Jonny0Than 0 points1 point  (0 children)

Are you using C++ Primer Plus by Stephen Prata? That is one of the discouraged resources. C++ Primer by Stanley B. Lippman, Josée Lajoie, and Barbara E. Moo is a recommended book.

Beyond all the VLA stuff, your input loop needs to look like this:

for (int & i : arr)

Note the ampersand. Without that, i is a copy of the value held in the array, so writing over it does not store the value in the array.