dimanche 25 mars 2018

short form of the condition of the conditionnel-if in c

(C-lang)

inline int is_empty(list head){
    return !head ? 1: 0;
}

I can see that "is_empty" function return 1 if the the list given is empty, 0 if it's not, also this short form of conditionnel-if is understandable, but can anyone explain to me how the condition works here, I mean how does the symbol '!' works with a pointer empty and does the cond-if just accepts 1 as true or any value except NULL is enough for the condition to be verified. thanks, I wish this could be understandable.

Aucun commentaire:

Enregistrer un commentaire