function
<cwctype>

iswpunct

int iswpunct (wint_t c);
Check if wide character is punctuation character
Checks whether c is a punctuation character.

A puctuation character is a character considered by a specific locale as a punctuation mark. These are characters with a graphical representation (as in iswgraph) that are necessarily non-alphanumerical (as in iswalnum).

This function is the wide-character equivalent of ispunct (<cctype>): If c translates with wctob to a character for which ispunct is true, it is always considered a punctuation character by this function (except possibly for certain locale-specific printable white-space characters other than L' ').

In C++, a locale-specific template version of this function (ispunct) exists in header <locale> for all character types.

Parameters

c
Wide character to be checked, casted to a wint_t, or WEOF.
wint_t is an integral type.

Return Value

A value different from zero (i.e., true) if indeed c is a punctuation character. Zero (i.e., false) otherwise.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* iswpunct example */
#include <stdio.h>
#include <wctype.h>
int main ()
{
  int i=0;
  int cx=0;
  wchar_t str[] = L"Hello, welcome!";
  while (str[i])
  {
    if (iswpunct(str[i])) cx++;
    i++;
  }
  wprintf (L"The sentence contains %d punctuation characters.\n", cx);
  return 0;
}

Output:
The sentence contains 2 puntuation characters.


See also