Charles Tritt
/
21_ConsoleIO_v5
Use this project as a starting point for simple IO testing in Mbed. This is the initial version.
Diff: main.cpp
- Revision:
- 115:f22cbbc92bae
- Parent:
- 114:1cfad1babb55
- Child:
- 116:a08f67e4d8e1
diff -r 1cfad1babb55 -r f22cbbc92bae main.cpp --- a/main.cpp Tue Oct 12 21:48:12 2021 +0000 +++ b/main.cpp Wed Oct 13 14:27:35 2021 +0000 @@ -1,5 +1,5 @@ /* -Project: 21_ScopeEx1_v5 +Project: 21_ConsoleIO_v5 File: main.cpp This simple program demonstrates that C passes arguments by value. @@ -18,17 +18,16 @@ const char ESC = 27; // Define escape character for escape sequence. printf("%c[2J%c[H", ESC, ESC); // ANSI/VT100 clear screen/home. - int count1 = 1; // Declared in outer block + // Replace the code below with your code. + int count = 1; // Declared in outer block. + int iCount = 0; // This is another variable called count. + do { + --iCount; // this applies to inner count. + printf("Count Down = %d and abs(Count Down) = %d\n", + iCount, abs(iCount)); + } while( ++count <= 5); // This works with outer count. - do { // Do while construct may be new to you! - int count2 = 0; // Declared & initialized in inner block - ++count2; // Ineffective due to line above! - printf("count1 = %d count2 = %d\n", count1, count2); - // Note that count1 is incremented in while test! - } while (++count1 <= 5); // count2 no longer exists after loop exit. - - printf("count1 = %d\n", count1); - return 0; + printf("count = %d\n", count); // Inner count is dead. while(true) { // Main forever loop. ThisThread::sleep_for(DELAY); // Pause