You did not give sum an initial value.

Also, by using fgetc only, you will not be parsing numbers, but rather just reading characters.