Set countdown time with Keypad?

I can make a key do something like this:

Not without errors, you can't. The value in the [] on the declaration statement is the number of elements. Element indices start at 0.

But it was a mess and I didn't save the code.

Try something (that, preferably, isn't a mess) and show what you have.

Getting a key press is easy. Getting the key that was pressed is easy. Storing the character that corresponds to the key is easy. Incrementing the index after storing the character is easy. Adding a NULL after adding each character is easy. Converting the stored data to a number is easy. Doing all these things at the right place in the code, in the right order is the only challenging part.