Friday, 15 March 2013

How to Initialize array in c? -


I have written this code, but on the compilation I get the message "Invalid expression" for the following statement Unsigned short address [] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; / * Array is being initialized here. There is no problem here too. * / Unsigned short line head = 3; Unsigned small colHead = 0; Unsigned tiny row = 0; Unsigned small coltile = 0; Unsigned small foods; Unsigned low food items; Unsigned short turn = 0; Zero gameover () {unsigned minus i = 0; Address [] = {0b10000001,0b01000010,0b00100100,0b00011000, 0b00011000,0 b 0000100100,00101000010,0b10000001}; / * This is the line where compiler complaints are in the form of invalid expression. * / While (1) {PORTD & amp; = ~ (1 ); PORTB = Address [i]; Delay_ms (5); PORTD | = 1 & lt; & Lt; I; I% 8; }}

You can only do this when declared at the same time and Specify. You can not do this later, you can create another variable and allocate it, however:

  unsigned short address 2 [] = {0b10000001,0b01000010,0b00100100,0b00011000, 0b00011000 , 0b 000010010000100100000010,0b10000001}; Address = address2;   

This can be , create problems with the size (address) ; If you need it, it is better to use just one more variable.

No comments:

Post a Comment