Next: Strings Up: Arrays Previous: Arrays

Single and Multi-dimensional Arrays

Let us first look at how we define arrays in C:

BEWARE: In C Array subscripts start at 0 and end one less than the array size. For example, in the above case valid subscripts range from 0 to 49. This is a BIG difference between C and other languages and does require a bit of practice to get in the right frame of mind.

Elements can be accessed in the following ways:-

Multi-dimensional arrays can be defined as follows:

for two dimensions.

For further dimensions simply add more [ ]:

Elements can be accessed in the following ways:


Dave.Marshall@cm.cf.ac.uk
Wed Sep 14 10:06:31 BST 1994