[CSI] character variable
Mikhail Nesterenko
mikhail at cs.kent.edu
Mon Jan 29 17:01:52 EST 2018
> I was looking at the slides and was reading about a character
> variable. I was wondering what the point of using one? can you give me an
> example or a better explanation?
Character variable holds a single character. It is used to process
text.
char a, b, c, d, e;
a = 'H';
b = 'e';
c = 'l';
d = 'l';
e = 'o;;
cout << a << b << c << d << e;
outputs
Hello
Here is another example:
char charInput;
cin >> charInput;
if(charInput == 'x')
cout << "You input letter x" << endl;
Unlike string constants, that can contain multiple characters, a
character variable or constant can contain only a single character.
Thanks,
--
Mikhail
More information about the cs13001
mailing list