|
|
View previous topic :: View next topic |
Author |
Message |
j_s_connell
Joined: 02 Feb 2004 Posts: 17
|
String woes |
Posted: Thu Nov 04, 2004 5:40 pm |
|
|
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
|
|
Posted: Fri Nov 05, 2004 3:14 am |
|
|
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 |
Posted: Sat Nov 06, 2004 6:11 pm |
|
|
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. |
|
|
|
|
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
|