It is outputting squares after 4 symbols

Welcome to the forum

char input[4];

To hold a 4 character string with its zero termination you need an array of chars with 5 elements. As written, the string is not terminated properly

Maybe take a look at Keypad data entry. A beginners guide for some ideas