10 years, 8 months ago.

I dont get these errors....

Hi,

I don't get these errors...

Thats my code:

Import programledmatrix

errors

If you compile it, you'll see the errors. Target board is Nucleo F401RE.

can somebody please help me?

Thanks Bagbag

2 Answers

10 years, 8 months ago.

It is handy to just copy the error, so we can see it without compiling ourselves.

Anyway this line:

void animate(int animation[][10] animation, int cycles, bool inverted = false)

Has a second time animation written, that one should be deleted, then it compiles (for LPC1768 at least).

However next line won't work:

int frames = sizeof(animation) / 320;

sizeof(animation) will return 4 always, the length of the pointer. See for example: http://www.cplusplus.com/faq/sequences/arrays/sizeof-array/

Patrick H.
poster
10 years, 8 months ago.

Thank you for you help.

Oh, I'm used to C# syntax. There I would have int[][10] animation, thats why I unintentionally added the name at the end again.

Why is it a pointer? I didn't used * oder & anywhere. May I should check what sizeof really does.

An array in C(++) is simply a pointer to the first element of the array. If you make an array, and use sizeof on it, it will return the size of the array in bytes. However if you supply that array to a function, it will only know that it is a pointer to an element, and it will have lost the information regarding the length of the array.

posted by Erik - 15 Mar 2014