dimanche 23 avril 2017

Issue with if / else statements in C

I'm having a little trouble with my if / else structure. I'm new to C and programming in general. So, for " num = 65279 ", I'm not really sure why, this if / else structure I wrote ends up going into the first if, as expected, but also goes into the last if ("if(num <= 65535"). I'm not sure why this is happening, since I used the { } correctly. How can I better restructure my code so that this error doesn't happen any more. Or what am I doing for that error to happen?

I'm using Linux gcc compiler

if(num >= 55296 && num < 56320){ 
        ...
}
    else{   

        if(num <= 127){
                ...
                      }
        else{
            if(num <= 2047)
            {
                ...
            }
            else{
                if(num <= 65535)
                {   ...
                }
                }
            }
        }

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire