Funktionen iswpunct () i C ++ kontrollerer, om det givne brede tegn er en tegnsætning eller ej.
Funktionen iswpunct () er defineret i headerfilen.
iswpunct () prototype
int iswpunct (wint_t ch);
Funktionen iswpunct () kontrollerer, om ch er et tegnsætningstegn eller ej. Som standard er tegnsætningstegnene
! "# $% & '() * +, -. /:;? @ () _` (|) ~.
iswpunct () Parametre
- ch: Den brede karakter, der skal kontrolleres.
iswpunct () Returværdi
- Funktionen iswpunct () returnerer værdien ikke nul, hvis ch er et tegnsætningstegn.
- Det returnerer nul, hvis ch ikke er et tegnsætningstegn.
Eksempel: Hvordan fungerer iswpunct () -funktionen?
#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; )
Når du kører programmet, vil output være:
स er ikke et tegnsætningstegn ~ er et tegnsætningstegn