Use subscripting and pointer notations with arrays : array « Array « C++ Tutorial






#include <iostream>
using std::cout;
using std::endl;

int main()
{
   int b[] = { 10, 20, 30, 40 };
   int *bPtr = b;

   for ( int i = 0; i < 4; i++ )
      cout << *( b + i ) << '\n';

   for ( int j = 0; j < 4; j++ )
      cout << bPtr[ j ] << '\n';

   for ( int i = 0; i < 4; i++ )
      cout << *( bPtr + i ) << '\n';

   return 0;
}
10
20
30
40
10
20
30
40
10
20
30
40








4.1.array
4.1.1.Initializing an array
4.1.2.Initializing an array in a declaration.
4.1.3.Static arrays are initialized to zero.
4.1.4.Passing arrays and individual array elements to functions
4.1.5.Linear search of an array
4.1.6.Use subscripting and pointer notations with arrays
4.1.7.array of strings
4.1.8.Obtaining the number of array elements