From 4e4501e0b42c2cca7fb25d82e21928f847304e38 Mon Sep 17 00:00:00 2001 From: Bobbi Webber-Manners Date: Sat, 5 May 2018 00:02:29 -0400 Subject: [PATCH] A few more notes about array initializers --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 39516ea..8c20956 100644 --- a/README.md +++ b/README.md @@ -288,7 +288,9 @@ Initializer lists must be no longer than the number of elements in the array. T word bad[3] = {1, 2, 3, 4}; ' INITIALIZER LIST TOO LONG! -If the initializer list is shorter than the number of elements in the array then the remaining elements are set to zero. +If the initializer list is shorter than the number of elements in the array then the remaining elements are set to zero. The empty list initializes all elements to zero: + + word allzero[10] = {} It is also possible to use string literals as array initializers. This is usually used with arrays of `byte` to initialize strings, for example: @@ -299,10 +301,14 @@ The array `msg` will be initialized to the character values of the string litera byte aa[4] = "ABC"; # Okay byte aa[4] = "ABCD"; # TOO LONG! -Finally, note that string literals may also be used to initialize `word` arrays: +Note that string literals may also be used to initialize `word` arrays: word vals[10] = "ABCABCABC" - + +Since the Commodore VIC20 and C64 lack the `{` and `}` symbols, `[` and `]` are used in their place, for example + + word commodore[10] = [10, 9, 8 ] + #### Array Indexing Array elements begin from 0, so the array `storage` above has elements from 0 to 9.