char c = 255;
if (c > 128)
printf("This is unsigned number %d\n", c);
printf("This is signed number %d\n", c);
This isn't well-defined behavior. The relevant part of the standard 126.96.36.199 §3:
Otherwise, the new type is signed and the value cannot be represented in it; either the result is implementation-defined or an implementation-defined signal is raised.
This means that the result depends on the compiler. Probably, your compiler attempts some sort of wrap-around based on two's complement - that's the most common behavior. It is not undefined behavior.
Please note that the
char type could be either signed or unsigned, that also depends on the compiler.