Tuesday, August 31, 2010

Arrays revealed (1 d mainly) in cpp

First, there are only one-dimensional arrays in C or C++. The number of elements is put between brackets:

Expand|Select|Wrap|Line Numbers
  1. int array[5];
  2.  
That is an array of 5 elements each of which is an int.

Expand|Select|Wrap|Line Numbers
  1. int array[];
  2.  
won't compile. You need to declare the number of elements.

No comments:

Post a Comment