char sNames[7] = {'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sun'};Serial.print(sNames[1]);
char* sNames[] = { "Sun" // 0 , "Mon" // 1 , "Tue" // 2 , "Wed" // 3 , "Thu" // 4 , "Fri" // 5 , "Sat" // 6};Serial.print(sNames[1]);
Is there a way to do something like this:Code:char sNames[7] = {'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sun'};
char sNames[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sun"};
Or,Code: [Select]char sNames[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sun"};
Quote from: guix on Jan 08, 2013, 02:09 pmOr,Code: [Select]char sNames[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sun"};What does that actually do? And specifically, what does it do if the number of characters in an initialiser string is not 3?
Quote from: PeterH on Jan 08, 2013, 03:55 pmWhat does that actually do? And specifically, what does it do if the number of characters in an initialiser string is not 3?That would create a matrix like this
What does that actually do? And specifically, what does it do if the number of characters in an initialiser string is not 3?
Strings should be null terminated, hence 4 instead of 3.
Simply allocate space that is not used.
And the second question?
That's if the initialiser is smaller than the declared size. What about the other case?