access out of range

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
2,411件の閲覧回数
electronicfan
Contributor II
hello,

i have a little problem:

I get an error message: access out of range

my code:

unsigned char my_func(void)
{
.....
return(array[8]);
}

This function is outsite of main.c
Hope somebody can help me.
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,347件の閲覧回数
bigmac
Specialist III
Hello electronicfan,

Assuming that you decare an array to contain eight elements,

unsigned char array[8];

The first element of the array will be array[0] and the last element will be array[7].  The element array[8] does not exist.

Regards,
Mac

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
1,347件の閲覧回数
bigmac
Specialist III
Hello,

What size have you declared for the global array?  To return the array[8] element, the array size would need to be 9, or more.

Regards,
Mac

0 件の賞賛
返信
1,347件の閲覧回数
electronicfan
Contributor II
hello Mac,

i have a global array of 8 bytes and i will return all 8 bytes to my main function.

Hope you can help me.


electronicfan



0 件の賞賛
返信
1,348件の閲覧回数
bigmac
Specialist III
Hello electronicfan,

Assuming that you decare an array to contain eight elements,

unsigned char array[8];

The first element of the array will be array[0] and the last element will be array[7].  The element array[8] does not exist.

Regards,
Mac
0 件の賞賛
返信