That's not really the way to think about it. Yes, you need a 5 element array. The NULL starts in position 0. When you overwrite that position with a key press value, you move the NULL to the next position.
arraya[j++] = key;
arraya[j] = '\0'; // Keep the array NULL terminated.
Honestly it took me a while to get the concept of arrays so I do appreciate you explaining it further. One last question the \0 moves the "Forced End" to the end of the array no matter how many keys are entered. Do I understand this correct?
Lets look at this function for a second and think about what it does. First you create an array to hold four characters in a string. You populate it with '1','2','3','4'. Then you read ONE character from the keypad and put it in the first position of the array. Then this function exits. You've read exactly one character, not 4.
Now when we go into this function again, we first reset that array to '1','2','3','4'. We lose that key that you just put in there last time. And now we again read ONE value and put it in the first slot of the array, do some printing and exit.
Next time in we throw away that value just read, reset the array to '1','2','3','4' and read ONE key again.
So you see that you will never get any 4 digit passcode. You only read 1 character from the keypad and then when you get ready to read another you throw away the old one. You only want to reset that array when you've read a full passcode from it.
I see. In my thought pattern (which was obviously wrong), I was taking it as it wouldn't exit the function until the ending key was pressed. In this case the *.
Your "plan" is wrong. The array, whether you declared it to have one character or one hundred, will be created each time you enter the changetime function. It will then, probably, read ONE character from the keypad and then it will exit the function, at which time your planning falls apart because arraya will be destroyed.
You need to learn the concept of scope of variables.
I agree but thats why i'm here ;) practice, learn, advance. Don't get me wrong, I don't post here to get the answers handed to me but to see what I have misunderstood which in this case was actually a good bit so I do appreciate all of you. (Yes you too @septillion). I will correct my mistakes and continue.