CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Array define...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hmmpic



Joined: 09 Mar 2010
Posts: 314
Location: Denmark

View user's profile Send private message

Array define...
PostPosted: Tue Nov 25, 2014 4:25 am     Reply with quote

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: 19497

View user's profile Send private message

PostPosted: Tue Nov 25, 2014 9:12 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Nov 25, 2014 12:40 pm     Reply with quote

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"};
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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