If it enters the loop with -1 you will get the same exception. The values need to be between 0 and 4 (inclusive). Surely arrays work the same way in C++, dont they?
Type: Posts; User: Cornix
If it enters the loop with -1 you will get the same exception. The values need to be between 0 and 4 (inclusive). Surely arrays work the same way in C++, dont they?
An array with a size of 5 can hold exactly 5 elements at the indices 0, 1, 2, 3 and 4.
You tried to access the index 5, which would be the sixth element in the array, and this index is out of...
Do you really want to do this with numbers? I can see that this probably makes for a better learning experience, but the more simpler way would be to cast the number to a string and to iterate over...