Hot!Declaring and initialising a number of arrays

Page: 12 > Showing page 1 of 2
Author
swmcl
Super Member
  • Total Posts : 218
  • Reward points : 0
  • Joined: 2014/05/10 13:54:42
  • Location: Queensland
  • Status: offline
2018/06/12 21:23:48 (permalink)
0

Declaring and initialising a number of arrays

Hi,
 
Beginners gunna break things ...
 
I'm trying to declare and initialise a number of arrays.  48 arrays of 20 bytes each actually.  I seem to have popped something.  message _01 is on line 20.
 
It accepts the first array.
 
Then the compiler error says, ... messages.c:21: error: (196) struct/union required
 
and keeps saying the same error till line 28 (message_09).  Then it accepts message_10 through to message_25.  Then rejecting message_26 through to message_33 and then accepting message_34 through to message_48.
 
So accept 1 then reject 8 then accept 16 and then reject another 8 and then accept the remaining 15.
 
the .c file section:
 

/**
  Section: Global Variables
*/

uint8_t message_01[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x31};
uint8_t message_02[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x32};
uint8_t message_03[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x33};
uint8_t message_04[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x34};
uint8_t message_05[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x35};
uint8_t message_06[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x36};
uint8_t message_07[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x37};
uint8_t message_08[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x38};
uint8_t message_09[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x39};
uint8_t message_10[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x31};
uint8_t message_11[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x32};
uint8_t message_12[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x33};
uint8_t message_13[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x34};
uint8_t message_14[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x35};
uint8_t message_15[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x36};
uint8_t message_16[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x37};
uint8_t message_17[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x38};
uint8_t message_18[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x39};
uint8_t message_19[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x31};
uint8_t message_20[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x32};
uint8_t message_21[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x33};
uint8_t message_22[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x34};
uint8_t message_23[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x35};
uint8_t message_24[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x36};
uint8_t message_25[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x31};
uint8_t message_26[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x32};
uint8_t message_27[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x33};
uint8_t message_28[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x34};
uint8_t message_29[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x35};
uint8_t message_30[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x36};
uint8_t message_31[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x37};
uint8_t message_32[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x38};
uint8_t message_33[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F. 0x72, 0x39};
uint8_t message_34[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x31};
uint8_t message_35[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x32};
uint8_t message_36[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x33};
uint8_t message_37[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x34};
uint8_t message_38[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x35};
uint8_t message_39[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x36};
uint8_t message_40[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x37};
uint8_t message_41[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x38};
uint8_t message_42[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x62, 0x61, 0x63, 0x6B, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x39};
uint8_t message_43[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x31};
uint8_t message_44[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x32};
uint8_t message_45[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x33};
uint8_t message_46[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x34};
uint8_t message_47[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x35};
uint8_t message_48[20] = {0x44, 0x6F, 0x63, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x69, 0x64, 0x65, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x36};


 
the .h file is simple:


extern uint8_t message_01[20];
extern uint8_t message_02[20];
extern uint8_t message_03[20];
extern uint8_t message_04[20];
extern uint8_t message_05[20];
extern uint8_t message_06[20];
extern uint8_t message_07[20];
extern uint8_t message_08[20];
extern uint8_t message_09[20];
extern uint8_t message_10[20];
extern uint8_t message_11[20];
extern uint8_t message_12[20];
extern uint8_t message_13[20];
extern uint8_t message_14[20];
extern uint8_t message_15[20];
extern uint8_t message_16[20];
extern uint8_t message_17[20];
extern uint8_t message_18[20];
extern uint8_t message_19[20];
extern uint8_t message_20[20];
extern uint8_t message_21[20];
extern uint8_t message_22[20];
extern uint8_t message_23[20];
extern uint8_t message_24[20];
extern uint8_t message_25[20];
extern uint8_t message_26[20];
extern uint8_t message_27[20];
extern uint8_t message_28[20];
extern uint8_t message_29[20];
extern uint8_t message_30[20];
extern uint8_t message_31[20];
extern uint8_t message_32[20];
extern uint8_t message_33[20];
extern uint8_t message_34[20];
extern uint8_t message_35[20];
extern uint8_t message_36[20];
extern uint8_t message_37[20];
extern uint8_t message_38[20];
extern uint8_t message_39[20];
extern uint8_t message_40[20];
extern uint8_t message_41[20];
extern uint8_t message_42[20];
extern uint8_t message_43[20];
extern uint8_t message_44[20];
extern uint8_t message_45[20];
extern uint8_t message_46[20];
extern uint8_t message_47[20];
extern uint8_t message_48[20];
 

 
Thoughts? (apart from any relating to the guy at the keyboard that is ...)
 
#1

22 Replies Related Threads

    swmcl
    Super Member
    • Total Posts : 218
    • Reward points : 0
    • Joined: 2014/05/10 13:54:42
    • Location: Queensland
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/12 21:42:54 (permalink)
    0
    Oh no forgot the versions ...
    XC8 1.45
    MPLAB 4.20
    Linux
    post edited by swmcl - 2018/06/12 21:45:25
    #2
    1and0
    Access is Denied
    • Total Posts : 8465
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/12 22:04:25 (permalink)
    +2 (2)
    You use a period instead of a comma after the 18th element of the array.
    #3
    jtemples
    Super Member
    • Total Posts : 11006
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/12 23:07:50 (permalink)
    +1 (1)
    Is there a reason you didn't just use strings instead of typing out ASCII characters in hex?
    #4
    1and0
    Access is Denied
    • Total Posts : 8465
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/12 23:40:23 (permalink)
    0
    jtemples
    Is there a reason you didn't just use strings instead of typing out ASCII characters in hex?

    Is this still valid C without storing the null terminating character?
    uint8_t message_01[20] = "Mrs Brown shed door1";  // character array of 20 chars

    #5
    jtemples
    Super Member
    • Total Posts : 11006
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/12 23:55:50 (permalink)
    +2 (2)
    Is this still valid C without storing the null terminating character?

     
    It is explicitly permitted in the standard.  But it might result in a warning on some compilers.  But you can always initialize with { 'M', 'r', ... } if you want.
    #6
    swmcl
    Super Member
    • Total Posts : 218
    • Reward points : 0
    • Joined: 2014/05/10 13:54:42
    • Location: Queensland
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/13 00:49:48 (permalink)
    0
    Thank you 1&0.
     
    I am getting more blind every day.
     
    It isn't the best or prettiest method for sure.  I'm just going to be happy to make a prototype run to be honest.
     
    The suggestion,
     
    uint8_t message_01[20] = "Mrs Brown shed door1";  // character array of 20 chars
     
    breaks it.
    #7
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 2740
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/13 03:28:53 (permalink)
    +2 (2)
    [21]
    or
    []

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #8
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 2740
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/13 03:31:31 (permalink)
    0
    Account for the terminating NULL else how will the string function know where the last character was.
     

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #9
    1and0
    Access is Denied
    • Total Posts : 8465
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/13 07:12:28 (permalink)
    +2 (2)
    Gort2015
    Account for the terminating NULL else how will the string function know where the last character was.

    Depending on how OP wants to use the character array, which is _not_ a string.  The size of the array is known, full and fixed, so arr[19] is the last character. ;)
     
     
    #10
    1and0
    Access is Denied
    • Total Posts : 8465
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/13 07:15:05 (permalink)
    +1 (1)
    swmcl
    The suggestion,
    uint8_t message_01[20] = "Mrs Brown shed door1";  // character array of 20 chars

    breaks it.

    What do you mean by "breaks it"?  Perhaps you should be using a string, not a character array; especially if you're using the string library functions.
     
    <edit> Have you tried this
    uint8_t message_01[20] = {'M', 'r', 's', ' ', 'B', 'r', 'o', 'w', 'n', ' ', 's', 'h', 'e', 'd', ' ', 'd', 'o', 'o', 'r', '1'};

    as jtemples suggested?
    post edited by 1and0 - 2018/06/13 07:19:50
    #11
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 2740
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/13 07:43:09 (permalink)
    +1 (1)
    Just use strings, that will save you the trouble later when using string library.
    const char const *ar[]={"Royal","Wedding","equals","greed"};

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #12
    NKurzman
    A Guy on the Net
    • Total Posts : 16572
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Declaring and initialising a number of arrays 2018/06/13 09:22:28 (permalink)
    +1 (1)
    this String is in RAM:
    uint8_t message_01[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x31};


    this String is in Flash:
    const uint8_t message_01[20] = {0x4D, 0x72, 0x73, 0x20, 0x42, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x73, 0x68, 0x65, 0x64, 0x20, 0x64, 0x6F, 0x6F, 0x72, 0x31};
    #13
    jtemples
    Super Member
    • Total Posts : 11006
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/13 09:53:27 (permalink)
    +2 (2)
    this String is in RAM:

     
    As 1and0 pointed out above, the OP is not using strings.  Strings are null-terminated.
    #14
    NKurzman
    A Guy on the Net
    • Total Posts : 16572
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Declaring and initialising a number of arrays 2018/06/13 11:39:04 (permalink)
    0
    jtemples
    this String is in RAM:

     
    As 1and0 pointed out above, the OP is not using strings.  Strings are null-terminated.


    String / Array then.
    That is a Lot of RAM Data for many 8 Bit PICs.
    And Probably a waste of it
    #15
    1and0
    Access is Denied
    • Total Posts : 8465
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/13 11:50:09 (permalink)
    0
    NKurzman
    That is a Lot of RAM Data for many 8 Bit PICs.
    And Probably a waste of it

    48 * 20 = 960 bytes, and not using strings saves 48 bytes that would otherwise be the null characters. ;)
     
    #16
    malaugh
    Super Member
    • Total Posts : 350
    • Reward points : 0
    • Joined: 2011/03/31 14:04:42
    • Location: San Diego
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/13 12:58:09 (permalink)
    +2 (2)
    Looks like test code, all the strings are "Mrs Brown shed DoorX" with X a number. Unless the real strings are really all the same size its more efficient to do something like
     

    const char *Strings[] =
    {
    "This is string 1",
    "This another string",
    "Short String",
    "Very Very Long String"
    };

     
    #17
    1and0
    Access is Denied
    • Total Posts : 8465
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/13 13:07:07 (permalink)
    0
    malaugh
    Looks like test code, all the strings are "Mrs Brown shed DoorX" with X a number. Unless the real strings are really all the same size its more efficient to do something like

    Agree.  The arrays are all "Mrs Brown shed doorX", "Mrs Brown back doorX", "Doc Brown shed doorX", and "Doc Brown back doorX".
     
     
    #18
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 2740
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/13 13:29:53 (permalink)
    +1 (1)
    Mrs Brown's back door sad: sad

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #19
    1and0
    Access is Denied
    • Total Posts : 8465
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Declaring and initialising a number of arrays 2018/06/13 13:58:07 (permalink)
    0
    Gort2015
    Mrs Brown's back door sad: 

    I got a chuckle when I decoded that. mr green: mr green
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2018 APG vNext Commercial Version 4.5