Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/23/08 15:44
Modified:
  04/23/08 17:07

Read: times


 
#153890 - Problem with arrays (atmel 8052)
I've been trying to initialize a pretty big array, but I'm encountering some problems.

My first attempt looked like this:


const unsigned char font[] = {
{0x22,0x3c,0x1c,0x3c,0x3c,0x20,0x1c,0x22,0x1c,0x1c,0x22,0x3c,0x22,0x22,0x1c,0x20,0x1c,0x22,0x1c,0x08,0x1c,0x08,0x22,0x22,0x08,0x3e},
{0x22,0x22,0x22,0x22,0x20,0x20,0x22,0x22,0x08,0x22,0x24,0x20,0x22,0x22,0x22,0x20,0x26,0x22,0x22,0x08,0x22,0x14,0x36,0x22,0x08,0x20},
{0x3e,0x22,0x20,0x22,0x20,0x20,0x2e,0x22,0x08,0x22,0x28,0x20,0x22,0x26,0x22,0x3c,0x2a,0x3c,0x02,0x08,0x22,0x22,0x2a,0x14,0x08,0x10},
{0x22,0x3c,0x20,0x22,0x3c,0x3c,0x20,0x3c,0x08,0x02,0x30,0x20,0x22,0x2a,0x22,0x22,0x22,0x22,0xac,0x08,0x22,0x22,0x22,0x08,0x14,0x08},
{0x22,0x22,0x20,0x22,0x20,0x20,0x20,0x22,0x08,0x02,0x28,0x20,0x2a,0x32,0x22,0x22,0x22,0x22,0x20,0x08,0x22,0x22,0x22,0x14,0x22,0x04},
{0x22,0x22,0x22,0x22,0x20,0x20,0x22,0x22,0x08,0x02,0x24,0x20,0x36,0x22,0x22,0x22,0x22,0x22,0x22,0x08,0x22,0x22,0x22,0x22,0x22,0x02},
{0x1c,0x3c,0x3c,0x3c,0x3e,0x3e,0x1c,0x22,0x1c,0x02,0x22,0x20,0x22,0x22,0x1c,0x3c,0x1c,0x3c,0x1c,0x3e,0x22,0x22,0x22,0x22,0x22,0x3e}
};


After I tried compiling this code I got the following error:

FUNCTIONS.C(9): error C242: 'scalar': too many initializers


I've looked up the problem in google and found out that I need to change the syntax of my array a bit, and so I did, this is my second attempt:


const unsigned char font[] = {
{"\x22" "\x3c" "\x1c" "\x3c" "\x3c" "\x20" "\x1c" "\x22" "\x1c" "\x1c" "\x22" "\x3c" "\x22" "\x22" "\x1c" "\x20" "\x1c" "\x22" "\x1c" "\x08" "\x1c" "\x08" "\x22" "\x22" "\x08" "\x3e"},
{"\x22" "\x22" "\x22" "\x22" "\x20" "\x20" "\x22" "\x22" "\x08" "\x22" "\x24" "\x20" "\x22" "\x22" "\x22" "\x20" "\x26" "\x22" "\x22" "\x08" "\x22" "\x14" "\x36" "\x22" "\x08" "\x20"},
{"\x3e" "\x22" "\x20" "\x22" "\x20" "\x20" "\x2e" "\x22" "\x08" "\x22" "\x28" "\x20" "\x22" "\x26" "\x22" "\x3c" "\x2a" "\x3c" "\x02" "\x08" "\x22" "\x22" "\x2a" "\x14" "\x08" "\x10"},
{"\x22" "\x3c" "\x20" "\x22" "\x3c" "\x3c" "\x20" "\x3c" "\x08" "\x02" "\x30" "\x20" "\x22" "\x2a" "\x22" "\x22" "\x22" "\x22" "\xac" "\x08" "\x22" "\x22" "\x22" "\x08" "\x14" "\x08"},
{"\x22" "\x22" "\x20" "\x22" "\x20" "\x20" "\x20" "\x22" "\x08" "\x02" "\x28" "\x20" "\x2a" "\x32" "\x22" "\x22" "\x22" "\x22" "\x20" "\x08" "\x22" "\x22" "\x22" "\x14" "\x22" "\x04"},
{"\x22" "\x22" "\x22" "\x22" "\x20" "\x20" "\x22" "\x22" "\x08" "\x02" "\x24" "\x20" "\x36" "\x22" "\x22" "\x22" "\x22" "\x22" "\x22" "\x08" "\x22" "\x22" "\x22" "\x22" "\x22" "\x02"},
{"\x1c" "\x3c" "\x3c" "\x3c" "\x3e" "\x3e" "\x1c" "\x22" "\x1c" "\x02" "\x22" "\x20" "\x22" "\x22" "\x1c" "\x3c" "\x1c" "\x3c" "\x1c" "\x3e" "\x22" "\x22" "\x22" "\x22" "\x22" "\x3e"}
};


this time I'm getting this error:

FUNCTIONS.C(10): error C243: 'array[]': string out of bounds


I really have no idea how to deal with this.
Any idea anyone? help will be greatly appreciated!

List of 18 messages in thread
TopicAuthorDate
Problem with arrays (atmel 8052)            01/01/70 00:00      
   What compiler?            01/01/70 00:00      
   Strange way of declaring a font.            01/01/70 00:00      
      Why is it strange?            01/01/70 00:00      
   what compiler?            01/01/70 00:00      
      I'm using Keil uVision 3            01/01/70 00:00      
         That's not a Compiler...            01/01/70 00:00      
            Yeah, I ment Keil C51 - doesnt support 2D arrays?            01/01/70 00:00      
               Not valid syntax            01/01/70 00:00      
                  Andy I think you want a semi-colon at the end            01/01/70 00:00      
                     True:            01/01/70 00:00      
   Too large            01/01/70 00:00      
      Almost there!            01/01/70 00:00      
         Warning            01/01/70 00:00      
            Thanks you VERY VERY much!            01/01/70 00:00      
               You are welcome!            01/01/70 00:00      
   The number of dimensions is incorrect            01/01/70 00:00      
   problem was wrong method used            01/01/70 00:00      

Back to Subject List