Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> การเขียนโปรแกรม C

ฟังก์ชัน iswpunct() ใน C/C++

iswpunct() ตรวจสอบ wide character ว่าเป็น punctuation (เครื่องหมายวรรคตอน) หรือไม่ คืนค่า non-zero ถ้าใช่ 0 ถ้าไม่ใช่ ประกาศใน cwctype (C++) หรือ wctype.h (C)

ไวยากรณ์

int iswpunct(wint_t character);

ตัวอย่าง

#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.

'!' เป็น punctuation, 'a' ไม่ใช่