C++ Character functions


Tags:  cppstl

Following functions are a part of the <cctype> header file

Checking character class

Note: true is 1 and false is 0 in these functions

Changing case


Code to print ALL punctuation characters:

char c = numeric_limits<char>::min();
while (true) {
if (ispunct(c)) {
cout << c << " ";
}
c++;
// Stop when it overflows back to starting value
if (c == numeric_limits<char>::min()) {
break;
}
}
cout << endl;

Output:

! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~