@Devirider's answer will work, but it doesn't explain the issue. So let's look at what's happening with this function:
for(int i = 0, len = strlen(key); i < len; i++)
There are two logic issues in play here.
First, the if statement will check if the chars are digits, one by one. As soon as it finds the first digit, it executes the return statement and stops checking any further chars. That means that if there are any non-digits later, it didn't check them. The if statement should be checking for non-digits instead. If it finds one, then return false.
This brings us to the next issue - the return values. There are two different practices for return values that are contradictory to each other. One is the value returned from a terminating program. Specifically, it will return 0 when a program completes successfully and will return a non-zero value to indicate an aborted execution or an error. The non-zero can also indicate what the error or condition was when it terminated.
Then, there's the use of 0 and 1 (or any non-zero value). If you're using a number as a bool, you have to understand how the compiler interprets the values. Zero, or 0, is always interpreted as FALSE!!! Any other non-zero, positive or negative, including 1, is interpreted as TRUE. So, that means that the code above was returning false when intending to return true and vice versa.
Fix these problems and you're all set. ;-)