C/C++ 中的 iswblank() 函式
iswblank() 函式用於檢查傳遞的寬字元是否為空。它基本上是空格字元,同時它還考慮製表符 (\t)。此函式在 C 語言中宣告在 “ctype.h” 標頭檔案中,在 C++ 語言中宣告在 “cctype”” 標頭檔案中。
以下是在 C++ 語言中 isblank() 的語法:
int iswblank(wint_t char);
以下是 C++ 語言中 iswblank() 的示例:
示例
#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++;
}
}
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP