ฟังก์ชัน iswblank() ใช้เพื่อตรวจสอบว่าอักขระ wide ที่ส่งผ่านเป็นค่าว่างหรือไม่ โดยพื้นฐานแล้วจะเป็นอักขระเว้นวรรคและพิจารณาอักขระแท็บด้วย (\t) ฟังก์ชันนี้ประกาศในไฟล์ส่วนหัว "ctype.h" ในภาษา C และไฟล์ส่วนหัว "cctype"" ในภาษา C++
นี่คือไวยากรณ์ของ isblank() ในภาษา C++
int iswblank(wint_t char);
นี่คือตัวอย่าง iswblank() ในภาษา C++
ตัวอย่าง
#include <ctype.h>
#include <iostream>
using namespace std;
int main() {
wchar_t s[] = L"The space between words.";
int i = 0;
int count = 0;
while(s[i]) {
char c = s[i++];
if (iswblank(c)) {
count++;
}
}
cout << "\nNumber of blanks in sentence : " << count << endl;
return 0;
} ผลลัพธ์
Number of blanks in sentence : 5
ในโปรแกรมข้างต้น สตริงจะถูกส่งผ่านในตัวแปร s ฟังก์ชัน iswblank() ใช้สำหรับตรวจสอบช่องว่างหรือช่องว่างในสตริงที่ส่งผ่าน ดังแสดงในตัวอย่างโค้ดต่อไปนี้
wchar_t s[] = L"The space between words.";
int i = 0;
int count = 0;
while(s[i]) {
char c = s[i++];
if (iswblank(c)) {
count++;
}
}