0

I wrote a function to check key which has or has not alphabetic character. And It give me that error. Here is my code. and that is also point 112-line } in error.

int checkAlpha(string alpha)
{
    for (int i = 0, n = strlen(alpha); i < n; i++)
{
    if (isalpha(alpha[i]))
    {
    return 0;
    }
    else
    {
    printf("Error! You should enter alphabet character!");
    return 1;
    break;
    }
}
} (this is line 112)
0
2

It means that the compiler sees a way that the program could end without a return being executed. In this case, if strlen(alpha) = 0, then the for loop will never execute and no return would be executed.

This can be fixed by adding a return outside the loop at the end of the function.

If this answers your question, please click the check mark to accept this and remove the question from the unanswered pool. Let's keep up on forum maintenance. ;-)

This is a duplicate of: How to solve "control may reach end of non void function" error

Not the answer you're looking for? Browse other questions tagged .