arrays

I really need help with arrays. Can anyone help me!!!!!!!!!!!!!!!!!
You have an entire forum ready to help you understand arrays.

What are you having trouble understanding?
It's an abstraction of data stored in a sequence.

Instead of a single data type with a single value, an array is a sequence of values that you can index through for whatever reasons, all within one identifier of those values.

For example, a non-array integer can be understood like this:

INTEGER CAT = 1 < -- Numeric integer data type.

And an array like this:

INTEGER CAT = [10] < -- Ten indices within the same data type indentifier "CAT".

You can set a value for each index of the array in sequence, and iterate through them, etc. They can be used pretty much like any non-array.

INTEGER CAT [1] = 1

INTEGER CAT [2] = 2

INTEGER CAT [3] = 3

And so on....
Last edited on
int is a number...

int array is a whole bunch of numbers...
An array is like a box of chocolates.
I wish I could new[] chocolates with the same effort.
Go outside the bounds of an array, you never know what you're gonna get.
Don't try to manipulate pointer returned via new[], as it may loose information to delete the allocated array like as given below.

1
2
3
4
5
6
7
int main()
{
    int * p = new int [10];
    p++;             //Can be dangerous
    delete [] p;  //as operator delete starts deleting an array of 10 pointers    starting from p+1

}


It's not dangerous, you just have to be sure you can get back the original. delete[] (p-1); would work in that case, but it would be really ugly.
Topic archived. No new replies allowed.