Control may reach end of non-void function Error

Hello all, while designing my validation function which checks if the first letter of a string is alphabetical, I run into the following error:


Control may reach end of non-void function


What does this mean? And how can I fix this?

Here is the function:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
bool validateString (const string & s)
{
    int count = 0;
    
    for (char c : s)
    {
        if (count == 1)
            return false;
        
        if (!isalpha(c))
            return true;
        
        if (isdigit(c))
            return true;
        
        count++;
    }
}


Thanks,
VX
Ok, never mind.

I fixed my problem by placing

 
return false;


after line 17.

I am leaving this question here because other people might have this problem.

-VX
Last edited on
Topic archived. No new replies allowed.