ฟังก์ชัน iswpunct() ใช้เพื่อตรวจสอบว่าอักขระที่ส่งผ่านนั้นเป็นเครื่องหมายวรรคตอนหรือไม่ คืนค่าศูนย์ หากไม่ใช่เครื่องหมายวรรคตอน มิฉะนั้นจะส่งกลับค่าที่ไม่ใช่ศูนย์ มันถูกประกาศในไฟล์ส่วนหัว “cwctype”
นี่คือไวยากรณ์ของ iswpunct()
int iswpunct(wint_t character);
นี่คือตัวอย่างของ iswpunct()
ตัวอย่าง
#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;
} ผลลัพธ์
The character is a punctuation. The character is not a punctuation.
ในโปรแกรมข้างต้น จะมีการประกาศอักขระกว้างสองตัวเป็น a และ b มีการตรวจสอบอักขระว่าอักขระที่ส่งผ่านเป็นเครื่องหมายวรรคตอนหรือไม่
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.");