C++ For Loop crash [4.6.1]
I don't get any errors in my code when compiling but on (Play) it crashes
Here's my code -
This is the crash message i get but i don't know how to fix it because it should work?
I'm assuming your "Inventory" array does not have 12 items in it. It has less. Say the size of the array is only three, that means you can only access those three members:
Once you start accessing items past the end of the array, you're accessing memory that is not part of that array (memory that doesn't have an inventory item stored in it). The crash assert you provided is guarding again you doing it. It's making sure the index (CheckNum) is within the bounds of your array.
To keep from using an invalid index, you probably want your for loop to look like this:
Using Inventory.Num() instead of 12, ensures that all the values of CheckNum are within the range of your array.
Hopes this makes sense!
Follow this question
Once you sign in you will be able to subscribe for any updates here