mardi 20 août 2019

Integer value promotion to unsigned int vs signed int in c [duplicate]

This question already has an answer here:

I have two c codes, the difference between them is that one uses char and one uses int, as follows,

First:

if case is true

int x = -1;
unsigned int y = 2;
if(x>y)

Second:

the if case is false

char x = -1;
unsigned char y = 2;
if(x>y)

Why does this happen?

Aucun commentaire:

Enregistrer un commentaire