jeudi 26 mai 2016

Something strange with if() in c

This is for a school project I'm working on, it's just a small part of the code but for some reason the program doesn't seem to go inside the if() no matter what the input is. I've tried anything and everything I know of (also used the isalpha() function) but it just won't run the commands inside the if().

do
{
    flag=1;
    gets(input.number);
    printf("\n%s\n",input.number);
    for(i=0;i<strlen(input.number);i++)
    {
        printf("yolo1\n");                                      //debug
        if(input.number[i]<48 || input.number[i]>57)            //PROBLEM HERE
        {
            printf("\nyolo2\n");                                //debug
            flag=-1;
            break;
        }
    }
    if(strlen(input.number)<1000 || strlen(input.number)>9999 || flag==-1)  printf("\nINVALID INPUT\n\nARI8MOS: ");
}while(strlen(input.number)<1000 || strlen(input.number)>9999 || flag==-1);

Can you guys help me out here??? I've been staring and the code for the better part of 3 days now....

Aucun commentaire:

Enregistrer un commentaire