:: Re: [DNG] Studying C as told. (For …
Top Page
Delete this message
Reply to this message
Author: Rainer Weikusat
Date:  
To: dng
Subject: Re: [DNG] Studying C as told. (For help)
KatolaZ <katolaz@???> writes:

[...]

> and the reason is that arrays in C are just syntactic sugar around
> memory addresses. This has nothing to do with polymorphism or generic
> programming, and is indeed much lower-level and more basic than
> that. Simply put, arrays do not effectively *exist* in C.


This is wrong. Arrays in C represent a finite set of consecutively allocated
objects of a certain type. For historical reasons (compatibility with
BCPL and B[*]), array indexing doesn't exist in C: It's by definition
equivalent to pointer arithmetic an expression with type 'array of T'
are automatically converted to a pointer of type 'pointer to T' pointing
to the first element of the array.

[*] In both languages, an array declaration instructed the compiler to
reserve a certain number of consecutive 'cells' (the only data type
available to both languages) and initialize the declared object with a
pointer to these cell range. The C convention was adopted to enable
structures containing arrays to 'map naturally to the memory of the
machine' while still enabling B programs expecting to get a pointer to
an array when trying to access it to work.