freepascal - Pascal - size of array -


I have a code in which I write each number in 1 line until I write it. I am confused about the size of the array In the beginning I have declared that the array with the A1 to 5 is array. But when I keep writing and put more than 5 numbers, it seems that it is still left and then the latter is used for bicycles. How is that possible? I thought I would get an error if I was out of the index.

  Programmasters; Var Hermes, I: Integer; A: array [1. 5] of integer; I started: = 0; Repetitive Inc (i); Readln (a [i]); If A [i] = 0 then HMEs: = I-1; Until one [i] = 0; I: for = 1 hmez do writeln (a [i]); End.  

You are overwriting memory which is a variable This can be a leak of memory due to an unrestricted exception (run-time error) or any other "strange" behavior sooner or later, in run-time probes of array indexes in 'managed' languages ​​such as C # or Java in parcel Optional feature is not mandatory, applicable language facility.

Pascal compilers usually have the option to turn on or off array index check, which is called 'class check', directive {$ R +} Changes - See.

In your case the code seems to be 'work', because there is probably no other useful variable, after the space allocated for A please note in memory it is just an incredible And this can not happen in all the runways of your program. So generally, your program is wrong.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -