User Tools

Site Tools


cs509:cplusplus_array_example_1

Example: C++ array

// array.cc
// First arrays example

#include<iostream>

using namespace std;

int main()
{
   int myArray[ 50 ];
   int i;
   
   for ( i = 0; i < 50; i++ )
   {
       myArray[ i ] = i;
       cout << "\n" << i << " = " << myArray[ i ];
   }

   cout << "\n" << myArray[ 50 ]; // fencepost error

   return 0;
}
cs509/cplusplus_array_example_1.txt · Last modified: 2013/03/06 19:01 by jchung

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki