0

When Should I use char?

10th Oct 2016, 12:30 PM
Felipe Idrobo
Felipe Idrobo - avatar
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!
10th Oct 2016, 3:44 PM
Schindlabua
Schindlabua - avatar