Konwersja typu - niepodpisana do podpisanego int / char
Próbowałem wykonać poniższy program:
#include <stdio.h>
int main() {
signed char a = -5;
unsigned char b = -5;
int c = -5;
unsigned int d = -5;
if (a == b)
printf("\r\n char is SAME!!!");
else
printf("\r\n char is DIFF!!!");
if (c == d)
printf("\r\n int is SAME!!!");
else
printf("\r\n int is DIFF!!!");
return 0;
}
Dla tego programu otrzymuję dane wyjściowe:
char jest DIFF !!! int jest SAMO !!!
Dlaczego otrzymujemy różne wyjścia dla obu?
Czy wynik powinien być taki jak poniżej?
char jest SAMO !!! int jest SAMO !!!