Array Basics

Posts 1–10 of 10 · Page 1 of 1
Array Basics
Going to try and do my best on explaining arrays (Sorry if it's wrong):

The Basics
My compsci teacher always tells me this: imagine a shelf, x by y, in which you can put items (variables) in the slots.

For example: a 3x3 array would look like this:
Code:
   |   |   
___|___|___
   |   |   
   |   |   
___|___|___
   |   |   
   |   |
Usually arrays work like regular grid boxes: you define them based on row and then column:
For example, (3,2) would refer to the box on the third row and the second column, usually.

Important things to know:
-In coding, everything starts at 0; if you want to look at the first row and the first column, instead of doing (1,1) you would do (0,0).

Arrays can also be three dimensional, four dimensional, or if you really want, 10 dimensional.

WIP, will get back to it later, but I gotta go and do something and I'm lazy to do a google doc.
I was looking for that because it's a quite hard to understand the arrays (and more for begginers like me). I have a question, does the arrays are the same on every programming language? (like C++ and C#). Thank you.
Quote Originally Posted by Zenitram View Post
I was looking for that because it's a quite hard to understand the arrays (and more for begginers like me). I have a question, does the arrays are the same on every programming language? (like C++ and C#). Thank you.
If you are talking about how arrays are stored, then yes, I believe so.
However, different languages might have different pieces of code (idk what it is called, my mind blanked out) to assign variables to arrays.
Quote Originally Posted by ASERHaerheadrherherh View Post
If you are talking about how arrays are stored, then yes, I believe so.
However, different languages might have different pieces of code (idk what it is called, my mind blanked out) to assign variables to arrays.
That is i was looking for, remembering how arrays are stored, doesn't matter if i need to use another language, it just the fact that i know how to use the arrays. Thank you for your answer.
Just want to mention that there is different types of arrays.

You have the standard that is like: [0|1|2|3|4]
This stores just a single value on each position.

Then you have array-of-arrays (jagged array) that is more like two rows:
[1|2]
[1|2]
[1|2]


And then as explained I think you have matrix array:
[1|2|3]
[4|5|6]
[7|8|10]



Might be wrong on some parts since I've not used arrays that much besides a single value array
-But they all are handy for their own things ofc
Nice, But how do 'nested' arrays get stored in memory?
Quote Originally Posted by Silent View Post
Nice, But how do 'nested' arrays get stored in memory?
IIRC arrays are just a pointer to a chunk of allocated memory. So the first array is just a bunch of pointers to your second arrays.
Quote Originally Posted by Nimboso View Post
IIRC arrays are just a pointer to a chunk of allocated memory. So the first array is just a bunch of pointers to your second arrays.
I had a feeling that's how it would work. Just could've been bothered googling xd.
Cheers for the information. It will be useful for the newer coders.
Thanks you very much
Posts 1–10 of 10 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us