C ++ ispunct () - C ++ standaardbibliotheek

De functie ispunct () in C ++ controleert of het gegeven teken een leesteken is of niet.

ispunct () Prototype

 int ispunct (int ch);

De ispunct()functie controleert of ch een leesteken is zoals geclassificeerd door de huidige C-locale. Standaard zijn de leestekens! "# $% & '() * +, -. /:;? @ () _` (|) ~.

Het gedrag van ispunct()is niet gedefinieerd als de waarde van ch niet kan worden weergegeven als unsigned char of niet gelijk is aan EOF.

Het wordt gedefinieerd in header-bestand "> header-bestand.

ispunct () Parameters

ch: het teken dat moet worden gecontroleerd.

ispunct () Retourwaarde

De ispunct()functie retourneert een waarde die niet nul is als ch een leesteken is, anders nul.

Voorbeeld: hoe de functie ispunct () werkt

 #include #include using namespace std; int main() ( char ch1 = '+'; char ch2 = 'r'; ispunct(ch1) ? cout << ch1 << " is a punctuation character" : cout << ch1 << " is not a punctuation character"; cout << endl; ispunct(ch2) ? cout << ch2 << " is a punctuation character" : cout << ch2 << " is not a punctuation character"; return 0; )

Wanneer u het programma uitvoert, is de uitvoer:

 + is een leesteken r is geen leesteken

Interessante artikelen...