Demonstrate what can happen when array limits are exceeded.

Dependencies:   mbed

Fork of SimpleConsoleTest by Charles Tritt

Revision:
1:a000e0121191
Parent:
0:2f9e67d4c561
Child:
2:80464803bc2f
--- a/main.cpp	Tue May 16 20:32:12 2017 +0000
+++ b/main.cpp	Thu Oct 12 19:57:14 2017 +0000
@@ -1,4 +1,7 @@
-#include "mbed.h"
+
+/*
+    File: main.cpp
+    Project: ArrayLimits
 
 //------------------------------------
 // Tera Term configurations
@@ -8,18 +11,25 @@
 //------------------------------------
 
 // Serial pc(SERIAL_TX, SERIAL_RX, 921600); // Highest Tera Term speed - works.
-Serial pc(USBTX, USBRX, 115200); // Highest common speed - works.
+// Serial pc(USBTX, USBRX, 115200); // Highest common speed - works.
 // Serial pc(USBTX, USBRX); // Default 9600 baud, alternate pin names - works.
-
-DigitalOut myled(LED1);
+*/
+#include "mbed.h"
 
 int main()
 {
-    int i = 1;
-    pc.printf("Hello World !\n");
-    while(1) {
-        wait(1);
-        pc.printf("This program runs since %d seconds.\n", i++);
-        myled = !myled;
+    float a[] {1.0, 3.0, 5.0, 7.0, 9.0 };
+    printf("Hello World !\n");
+
+    for (int i = 0; i > -10; i--) { // Displays zeros and one NaN.
+        printf("a[%d] is %f.\n", i, a[i]);
+        wait(0.5f);
     }
+    
+    for (int i = 0; i < 10; i++) { // Hangs after 6th value!
+        printf("a[%d] is %f.\n", i, a[i]);
+        wait(0.5f);
+    } 
+    
+    while (true) {}; // Just loop here forever after tests.
 }
\ No newline at end of file