What is the difference between an array's data structure and an array of type data in the context of a programming language such as C?

Wikipedia highlights Array Data Structure and Array Data-type .

What is the difference between the data structure of an array and a Data-type array in the context of a programming language such as C?

What is this int array[]={1, 2, 3, 4, 5};:?

Is this a data structure of an array or an array of type data? Why?

+5
source share
4 answers

Short answer: Do yourself a favor and just ignore both articles. I have no doubt about the good intentions of the authors, but the articles are confused at best.

What is this int array[]={1, 2, 3, 4, 5};:?

Is this a data structure of an array or an array of type data? Why?

, . , , , C. , C, , .

: , , - . , , , :

address = (base address) + (element index * size of a single element)

" " - 0.

, , , , . , ++ std::vector, Objective-C NSArray NSMutableArray, .

, , . , :

- , ( ),

, , :

- , ( ),

, , , -, C, , , , , , . , , , , "" .

+5

- , ; - , - . , , . - (, -, PHP).

C ; .

+3

, ( ), , . .

0

[] - , C

Similary, * - , C

int array[]={1, 2, 3, 4, 5};is an example of an array data structure in C

In particular, you defined a data structure that has 5 integers arranged in order, you allocated enough memory for the stack for this data structure, and you initialized this data structure with values ​​1, 2, 3, 4, 5.

A The data structure in C has a nonzero size, which can be found by calling sizeof () on an instance of this structure.

0
source

All Articles