'0' is a char and it has value 48. You can look up any ASCII table in the google.
It works this way because you read from the input char value not the int, so if you don't add "-'0'" part it will increment 48th cell of an array.
Instead of "-'0'" you can put "-48", in my opinion it's more readable this way.