+ 1
Lets say i create array like a[5] which means size of array is 5 ohk
but when i start entering elements like size of array is 5 but in for loop i put value from i = 1 to i= n where i say n is any size i can enter from my side. now i enter n= 10 and the program will start taking 10 values. now my question is how this is possible??? i created array of memory space 5 but i can specify the size to be even 10 or more and its working perfectly?? just how?
3 Respostas
+ 2
It may work to some extent only, but I would strongly suggest you not to rely on such things. In that event, the program writes the extra 5 values outside the boundaries of the memory allocated by system for the array, now, we don't know whether the 5 extra slots were actually free or used by other applications, or even the system itself, and eventually, that can trigger access violation (for writing in some other applications' memory space). And not to mention, it was not a good programming habit, a good coder must avoid such things : )
Hth, cmiiw
+ 1
thnx
+ 1
You're welcome : )