|
|
View previous topic :: View next topic |
Author |
Message |
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
Array define... |
Posted: Tue Nov 25, 2014 4:25 am |
|
|
Hi
Now I'm confused, how to define this array correct, it's only a demo for my problem?
Code: | const char AString[?][?]={"12","1234","123","1","12345678"}; |
I can put a little more information:
Code: | const char AString[][9]={"12","1234","123","1","12345678"}; //Here I put the longest array in it's 8+1. Now the compiler calculate the rest. This waste a lot of space. |
Code: | const char *AString[5]={"12","1234","123","1","12345678"};//This is pointer to 5 string, wont work in CCS? |
How to define with minimum over heat.
Hints? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Tue Nov 25, 2014 9:12 am |
|
|
Read the manual.
Look at the section "Using Program Memory for Data".
Look at what the '*' specifier is used for. |
|
|
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
|
Posted: Tue Nov 25, 2014 12:40 pm |
|
|
Thanks for hints:-)
The solution is on page 34 in the CCS PDF:
Code: | The compiler allows a non-standard C feature to implement a constant array of variable length
strings.
The syntax is:
const char id[n] [*] = { "string", "string" ...};
Where n is optional and id is the table identifier.
For example:
const char colors[] [*] = {"Red", "Green", "Blue"}; |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|