(Go: >> BACK << -|- >> HOME <<)

Comparison of Pascal and C: Difference between revisions

Content deleted Content added
clarifying
note about GetMem, old enough to be mentioned.
Line 176:
 
In Pascal, arrays are a distinct type from pointers. This makes [[bounds checking]] for arrays possible from a compiler perspective. Practically all Pascal compilers support range checking as a compile ''option''.
The ability to both have arrays that change length at runtime, and be able to check them under language control, is often termed "dynamic arrays". In Pascal the number of elements in each array type is determined at compile-time and cannot be changed during the execution of the program. Hence, it is not possible to define an array whose length depends in any way on program data. (Note : since 1986 and Turbo Pascal 3, which was the industry standard, <code>GetMem()</code> allows dynamic arrays in everyday Pascal, if not in the ISO standard)
 
C has the ability to initialize arrays of arbitrary length. The <code>[[sizeof]]</code> operator can be used to obtain the size of a statically initialized array in C code. For instance in the following code, the terminating index for the loop automatically adjusts should the list of strings be changed.