There are two things wrong with your code:
while
loop, you are setting k
to 0 and then saving the current letter into index k
of word
, that is, in index 0. So you are always overwriting the same array element. With the letters e
, v
, o
and l
in order. So the final value is l
.\0
chracters, 24 of these are printed before the l
.