Site icon Study Algorithms

What is an unsigned char?

Question:

In C, what is an unsigned char used for? How is this different from a regular char?

In C, there are three distinct character types:

If you are using character types for text, use the unqualified char:

It also works out as a number value, but it is unspecified whether that value is treated as signed or unsigned. Beware character comparisons through inequalities – although if you limit yourself to ASCII (0-127) you’re just about safe.

If you are using character types as numbers, use:

Exit mobile version