Your loop is overstepping the array.
Arrays are indexed from 0, so the condition in a loop like yours should always test with <
, never with <=
.
Also, you're printing single characters with %s
, which is also wrong. It should be %lc
for a single wide character.