jeudi 16 septembre 2021

why does if (x) return true no matter the number passed to it? [duplicate]

Why does if (x) return true no matter the size of the numbers being passed to it if it's declared as an int?

int x;
scanf("%d",&x);
if (x)
     printf("Roses\n");
else
     printf("Violets\n");

Unless I write anything non-numeric, it will always output Roses. I would have figured anything sized larger than an int would not return true.

Aucun commentaire:

Enregistrer un commentaire