check_dig: Declare variable at the top

C89 doesn't allow variable declarations to be intermingled with code.