You say int c = getchar()
which will retrieve "t"
.
Then when you say while (c = getchar())
it will retrieve "h"
, note that you did not even get a chance to print the character out since you called getchar
in the while
statement.
To fix this, declare int c = 0;
or int c;
Then when you call getchar()
in the while
loop you will start at the first character.