iswpunct() function in C/C++

CC++Server Side Programming

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.");
raja
Published on 05-Nov-2018 07:37:55
Advertisements