Getting weird behavior in if statement.

I think the char array is proper, but I could be wrong.

You definitely need more than 5 bytes (four characters plus zero terminator) in the digits array, as well as to keep in mind that array indexing begins with the 0th element.