C ++ iswpunct () - C ++ Standardbibliothek

Die Funktion iswpunct () in C ++ prüft, ob das angegebene breite Zeichen eine Interpunktion ist oder nicht.

Die Funktion iswpunct () ist in der Header-Datei definiert.

iswpunct () Prototyp

 int iswpunct (wint_t ch);

Die Funktion iswpunct () prüft, ob ch ein Interpunktionszeichen ist oder nicht. Standardmäßig sind die Satzzeichen

 ! "# $% & '() * +, -. / :;? @ () _` (|) ~.

iswpunct () Parameter

  • ch: Das zu überprüfende breite Zeichen.

iswpunct () Rückgabewert

  • Die Funktion iswpunct () gibt einen Wert ungleich Null zurück, wenn ch ein Interpunktionszeichen ist.
  • Es gibt Null zurück, wenn ch kein Interpunktionszeichen ist.

Beispiel: Wie funktioniert die Funktion iswpunct ()?

 #include #include #include using namespace std; int main() ( setlocale(LC_ALL, "en_US.UTF-8"); wchar_t ch1 = L'u0938'; wchar_t ch2 = L'u007e'; iswpunct(ch1) ? wcout << ch1 << L" is a punctuation character" : wcout << ch1 << L" is not a punctuation character"; wcout << endl; iswpunct(ch2) ? wcout << ch2 << L" is a punctuation character" : wcout << ch2 << L" is not a punctuation character"; return 0; )

Wenn Sie das Programm ausführen, lautet die Ausgabe wie folgt:

 स ist kein Interpunktionszeichen ~ ist ein Interpunktionszeichen

Interessante Beiträge...