Hi, I’m learning c/c++ and I dynamically declared an array, I entered more integers than I initialized the array for and I did not resize the array and it still worked!! I initialized the array with 5 elements and entered 10 and I was able to print 10 elements without resizing the array. is that supposed to happen or cLion does that for you? just because if I compile my code on a different system, I don’t want my program to crash!
Could you paste your exact code in a code fence so we know exactly what you mean? Like this:
``` yourCodeHere = ...; ```
For the record: I suspect you are indexing into invalid memory. Doing that will lead to memory corruption in real applications. If that is in fact what you are doing.
Aside: Java would give you an index out of bounds exception, but many (if not all) C languages do not (they just keep indexing to the next memory slot).