hi,  i have encountered something really strange, though...

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

hi,  i have encountered something really strange, though...

1,999件の閲覧回数
dashz84
Contributor I
hi,

i have encountered something really strange, though it may be the result of my limited experience with C.

when I initialized an array of int by saing

int array[]={0, 20, 40, 60 , 80, 100};

inside the Debugger, every value of array was set to -1.

also, if i initalize the array by saying

unsigned int array[]={the same as above};

the the debugger says that all the elements are equal to 65535.

Can someone please tell me what might be the possible causes for these symptoms?

thanks very much
ラベル(1)
タグ(1)
0 件の賞賛
返信
2 返答(返信)

1,137件の閲覧回数
dashz84
Contributor I
i also forgot to mention that if i specify the array as

int array={1,2,3,4,5} then the array is produced with the correct values,
however the code
int array={1,2,3,4,5,6,7,8,9,10} does not produce the desired array, instead it's an array of {1}'s.

furthermore, if I use 'unsigned int', instead of 'int', then i can only accuratly initialize the array with only 1 element, i.e. unsigned int array={1} is the only array length that woks.

any help is much appreciated
0 件の賞賛
返信

1,137件の閲覧回数
bigmac
Specialist III
Hello,
 
I assume that it is your intent that the array variable be located in RAM, and is declared as a global variable.  If so, when the project is created you will need to enable ANSI initialisation, for global variables to be properly initialised during startup.
 
Does this apply to your project?
 
Regards,
Mac