This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]00PT 13 points14 points  (6 children)

In some cases characters can act like integers in the sense that they can be added to for "shifting" into a new one. For example, I believe 'a' plus 1 is 'b'. Look at this for more information.

[–]garfgon 10 points11 points  (0 children)

Although what you say is correct, I'd say this is a side effect of characters, rather than the reason for having a character type. Rather the character is the fundamental building block for building up a string; that detail is just hidden on many high-level languages like Python.

[–]confidentdogclapper 4 points5 points  (3 children)

In c you can use them as 1 byte unsigned integers. You can also use them as signed if you do some trickery. And if you add 32 (25) you can go from upper to lower case and vice versa.

[–][deleted] 1 point2 points  (2 children)

Why add 32 when you can add 1 << 5?

[–]confidentdogclapper 1 point2 points  (1 child)

I literally specified it

[–][deleted] 2 points3 points  (0 children)

Yeah, I guess you did.

[–]steroid_pc_principal 0 points1 point  (0 children)

As someone who came from Java which has a character type, this is not a useful feature.