Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of ArraySizeof by
Diff: main.cpp
- Revision:
- 2:761d1c20f740
- Parent:
- 1:987d0ca5cf9a
- Child:
- 3:45a53383e09f
--- a/main.cpp Mon Oct 23 02:29:40 2017 +0000 +++ b/main.cpp Mon Oct 23 12:31:42 2017 +0000 @@ -2,8 +2,9 @@ Project: ArraySizeof File: main.cpp Ported to mbed/Nucleo by: Dr. C. S. Tritt - Last revised: 10/22/17 (v. 1.0) + Last revised: 10/22/17 (v. 1.1) + Demonstrates array output. */ #include "mbed.h" @@ -27,11 +28,11 @@ } // For mbed/Nucleo boards, the final \n is generally required to see output. - printf("\nSize of myNum = %u.\n", sizeof(myNum)); // Total size. - printf("Size of myNum[0] = %u.\n", sizeof(myNum[0])); // Row size. - printf("Size of myNum[0][0] = %u.\n\n", sizeof(myNum[0][0])); // Item size. + printf("\nElement size (sizeof(myNum[0][0]): %u.\n", sizeof(myNum[0][0])); + printf("Row size (sizeof(myNum[0]): %u.\n", sizeof(myNum[0])); // Row size. + printf("Array size (sizeof(myNum): %u.\n\n", sizeof(myNum)); // Total size. - // Calculated sizes. + // Output using calculated sizes. for (int r = 0; r < sizeof(myNum)/sizeof(myNum[0]); r++) { for (int c = 0; c < sizeof(myNum[0])/sizeof(myNum[0][0]); c++) { printf("%d ", myNum[r][c]);