Listing 8 5 IntArray

From ArduinoInfo
Jump to navigation Jump to search
/* Listing 8-5. Using an int array.

  Purpose: Display an int array using array indexes
  
  Dr. Purdum, Nov. 22, 2014
 */

void setup() {
  Serial.begin(9600);

  int greet[6];  // Notice this is an int now
  int *ptr;              // ...as is this
  int i;

  greet[0] = 0;     // Numbers now...
  greet[1] = 1;
  greet[2] = 2;
  greet[3] = 3;
  greet[4] = 4;
  greet[5] = 5;

  ptr = greet;
  for (i = 0; i < 5; i++) {
    Serial.print(greet[i]);
  }
}
void loop() {}