17.9.15

how to compare char in c++

Assume that c is a char variable that has been declared and already given a value. Write an expression whose value is true if and only if c is NOT what is called a white space character (that is a space or a tab or a newline-- none of which result in ink being printed on paper).

Solution
(c==' ' || c=='\t' || c=='\n') ? false : true

No comments:

Post a Comment

Comment Here