What is the difference between signed and unsigned char in C ? When I tried to run the following code without unsigned it entered an infinite loop as the range of signed char is up to 127 (Why is it signed by default ?). But when I added unsigned (whose range is up to 255) it works fine. What's the reason ?
#include <stdio.h>
int main() {
unsigned char x;
x = 0;
while (x <= 225) {
printf("%c=%d\n", x, x);
x = x + 1;
}
return 0;
}
charis signed or unsigned is implementation defined. I.e. two different compilers might have it differently.