0
When Should I use char?
1 Resposta
+ 1
Well, whenever you are dealing with only one character. Whenever you aren't dealing with text which you might write to a file or where you don't want to add more text to it, but whenever there's just a single character. Say you want to check whether the first character of a string is a capital X:
char capitalX = 'X';
if(myString[0] == capitalX){ ... }
I suppose if you are just starting out, you'll be mostly dealing with strings, but chars do have their uses. After all, a string is just a lot of chars in a row!