iswpunct() function in C/C++



The function iswpunct() is used to check that the passing wide character is a punctuation or not. It returns zero, if it is not a punctuation, otherwise it returns a non-zero value. It is declared in “cwctype” header file.

Here is the syntax of iswpunct()

int iswpunct(wint_t character);

Here is an example of iswpunct()

Example

#include<cwctype> #include<stdio.h> using namespace std; int main() {    wint_t a = '!';    wint_t b = 'a';    if(iswpunct(a))    printf("The character is a punctuation.");    else    printf("\nThe character is not a punctuation.");    if(iswpunct(b))    printf("\nThe character is a punctuation.");    else    printf("\nThe character is not a punctuation.");    return 0; }

Output

The character is a punctuation. The character is not a punctuation.

In the above program, two wide characters are declared as a and b. The characters are checked that passed character is a punctuation or not.

wint_t a = '!'; wint_t b = 'a'; if(iswpunct(a)) printf("The character is a punctuation."); else printf("\nThe character is not a punctuation."); if(iswpunct(b)) printf("\nThe character is a punctuation."); else printf("\nThe character is not a punctuation.");
Updated on: 2020-06-26T07:53:21+05:30

198 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements