Difference between Array and Record
Question by Guest | 2016-10-31 at 19:09
At the moment, I am learning programming at school and I am just wondering what the difference between an array and a record might be.
For me, both are types of data structures which can be used to store multiple values. So, why do we need two different terms for the same idea?
Related Topics
PHP: Remove all empty elements from string array
Tip | 0 Comments
JavaScript: Create and Use Arrays
Info | 0 Comments
Lazarus: Load File as Byte Array and save Byte Array as File
Tutorial | 0 Comments
Send Form Input as an Array to PHP Script
Tip | 0 Comments
PHP: Write array to individual Variables
Tutorial | 0 Comments
JavaScript: Sort Array of Numbers
Tutorial | 0 Comments
Delphi/Lazarus: Show Byte Array as String of HEX Values
Tip | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
Indeed, an array as well as a record are providing the possibility to store data in it. However, there is one important difference: an array can only be used for storing elements of the same type, while a record can contain multiple elements of a different type.
Here is a small example:
Here we have first declared two different arrays. The array intArr can only hold numbers (integer type), the array strArray only text (string type). After that, you can find the declaration of the record recPerson. This record can not only contain only numbers are only text, but lots of different types such as strings, a date and a number. arrPersons is an array that can only consist of elements of the type recPerson, so this array-record-combination is consisting of both concepts.
I hope that this example could clarify the difference between array and record.
2016-11-01 at 18:38