1. Yes, it produces UB. You try to put more characters in str1 than there is space for. str1 has space for 5 characters and the zero terminator, you try to put 31 and the zero terminator in that...