This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Declaring (initializing) array without size

Hi!

I'm having some problems declearing an array. I am trying to make an array that contains messages that I will later display on an LCD display. I am using a 2D char array, but I don't want to specify a fixed size to the second dimension. At the moment i am doing this:

const char message[][20] = {
	"RS232 Monitor",
	"By: Oyvind Tjervaag",
	"V1.0",
};

The problem with this is that a lot of space is wasted scince there is only one string that fills up the 20 chars. Here the "V1.0" string will be the 4 chars I want to use followed by 16 0x00...

The annoying thing about this is that I have have done it before.. But I can't find the code where I did it...

I thought I could do it like this:

const char message[][] = {...}
But that is just giving me the error, "Too many initializers" , which of course means that I am trying to add more variables than what can fit into the array.

Could someone give me any hints about this?

Thanks
Øyvind

Parents
  • Thanks for the fast reply.

    But.... neither functions seems to work.
    The first one come through the compiler but no string on the LCD. Infact, same result as I allready had.

    The other seems to bother the compiler.
    I get an error message error: need array size

    So.... I got dont know what to do....

Reply
  • Thanks for the fast reply.

    But.... neither functions seems to work.
    The first one come through the compiler but no string on the LCD. Infact, same result as I allready had.

    The other seems to bother the compiler.
    I get an error message error: need array size

    So.... I got dont know what to do....

Children