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.");

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 26-Jun-2020

110 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements