What is an array?

Could anyone tell me what an array is, what it is used for, and how to use it? I appreciate detail.

Thanks!
An array in a variable with multiple values, it allows you to "In my words" "Stack the same variable with different value". They allow you to use a single variable and attach different values to it. They are slightly more complex then normal variables, but allow lets say int x [5] = { 1,3,5,7,9};) x would equal all of these. If you wanted the second value you would call x[2] if you wanted the value 3, or x[4] if you wanted 7

Here is a better explanation on what they are

http://www.cplusplus.com/doc/tutorial/arrays/
Last edited on
Thanks, that was great! And do you know if it is possible to create an array with letters? I am trying to make a decoder for my "cipher" that I made, and I want to know if it's possible to store the pattern in an array. It's only a simple letter shift, so it's not too complicated.
Yes. You can make arrays of any type.
Let's Google it, dude ;)

Read this:
http://en.wikipedia.org/wiki/Array_data_structure

Wikipedia's Array data structure article.
closed account (z05DSL3A)
cstorm wrote:
int x [5] = { 1,3,5,7,9};)If you wanted the second value you would call x[2] if you wanted the value 3, or x[4] if you wanted 7

x[2] would actually by the value five and x[4] would be 9. Arrays are zero indexed, so the first element is at index 0, the second is index 1 and so on.
Note that an array is NOT a pointer, it sometimes decays into one.
Topic archived. No new replies allowed.