Arrays and Stacks

Arrays

Arrays are data structures that allow storage of and random access to multiple elements

To access a given element, use its index number, starting from 0.

Examples of Array Usage and random data access

The string type, for example, is simply an array of character values.

The word data, placed into a string variable called word, is an array which looks like this:

To access the t, for instance, you can use word[2]

Stacks

A stack allows data to be inserted and removed at only one end, called the top.

Stack Data Management

To manage data in stacks, the following functions are generally needed: