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

String woes

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



Joined: 02 Feb 2004
Posts: 17

View user's profile Send private message

String woes
PostPosted: Thu Nov 04, 2004 5:40 pm     Reply with quote

This question might be obvious to people, but i cant figure it out-
If I declare an array of const strings like so:

const char[256][16] = { {..}, .. };

The compiler tells me my subscript is out of range.
So I cant have 256 strings of 16 characters....

BUT, if i say:

const char[256][256] = {{..}, ..};

It compiles fine....

Likewise these wont work:

const char[64][64] = {..};
const char[32][32] = {..};

But this will:

const char[16][16] = {..};

Is this normal behavior, a bug, or have i just been staring at this screen to long?
Ttelmah
Guest







PostPosted: Fri Nov 05, 2004 3:14 am     Reply with quote

I'd suspect the compiler is treating the value as an 8bit integer. 256, is then 'seen' as '0'. As such, it is a fault in the parser.
The limit, involved in constant strings, depends on the chip. '18' family chips, should handle long string constants, but on the smaller chips, if the total size exceeds what can be put into one 'page' of the ROM, it will fail.

Best Wishes
Guest








Re: String woes
PostPosted: Sat Nov 06, 2004 6:11 pm     Reply with quote

j_s_connell wrote:


const char[256][16] = { {..}, .. };

The compiler tells me my subscript is out of range.
So I cant have 256 strings of 16 characters....

BUT, if i say:

const char[256][256] = {{..}, ..};

It compiles fine....



const char[256][16] = { Too many strings, or strings are longer than 16 chars };

Then you will get that message.

This works because
const char[256][256] = { strings you have here fit into 256,256};

it's that simple.
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