I'm not new to programming but I'm definitely new to C-style programming with manual memory management. So I was having this weird problem that I would love to be able to understand. I have - sort of - solved it already, but I don't understand why my solution works, and that bothers me.
The program is somewhat large for an arduino sketch, about 14k, and I was getting all sorts of really strange behavior - which made me suspect that there was some sort of memory issue somewhere - some address that being written to that shouldn't be written to or something like that.
After many hours of frustration and desperately trying to find the problem, I finally tracked it down to this array:
Increasing the outer dimension of this by 1 fixed the problem, like so:
The thing is though, I can't find anywhere in my code where I'm calling on or assigning any number above fingers[x]! So I do not understand at all why adding an extra slot to that array fixes my problems. I've seen at a couple of places that character arrays should be terminated by a null byte, so you should always add an extra char to those above from what you need for your text, but is this the case even with long-type arrays? Or what could possibly be going on here?