samedi 12 août 2017

C programming: Division in an if-statement

Why does it print 2 when the value of SIZE is greater than -1?

Link to the code: http://ift.tt/2uPfBGf

#include <stdio.h>
int array[] = {1,2,3,4,5,6,7,8};
#define SIZE (sizeof(array)/sizeof(int))

int main(void) {
    if(-1<=SIZE) printf("1");
    else printf("2");
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire