If Comparison

i can't get it to tell me if pCurrentChar is a number
i tried casting int i as char and it didn't work
the program compiles with no errors its just not doing what i want it to do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
int AI::CheckIfCharOrInt()// 1 is a number , 0 isn't a number
{
    int Check = 3;
    for( int i = 0; i < 10; i++)
    {
        std::cout << i << std::endl;
        std::cout << "  " << *pCurrentChar << std::endl;
        if ( *pCurrentChar == i )
        {
            
            Check = 1;
            
            break;
        }
        
    }
    if( Check = 3 )
    {
        Check = 0; //tells that it is a number
    }
    
    return Check;
    
            
}
To check if a character is a number, you can:

1
2
if( *pCurrentChar >= '0' && pCurrentChar <= '9' )
   return true;


or

 
return isdigit( *pCurrentChar );

Topic archived. No new replies allowed.