Consider following code:
That is because the int value of
-1, so what you're doing is loop until the expression
(c=getchar())+1) gets the value 0 which is when you read
EOF (where value of exrpession is: -1+1=0). Also as wll pointed out in the comments you should declare c as int since
getchar() returns int.