C / C ++中的isblank()
该函数isblank()用于检查传递的字符是否为空。它基本上是一个空格字符,并且还考虑了制表符(\t)。该函数在C语言的“ctype.h”头文件和C++语言的“cctype”头文件中声明。
这是isblank()C++语言的语法,
int isblank(int char);
这是isblank()C++语言的示例,
示例
#include <ctype.h>
#include <iostream>
using namespace std;
int main() {
string s = "The space between words. ";
int i = 0;
int count = 0;
while(s[i]) {
char c = s[i++];
if (isblank(c)) {
count++;
}
}
cout << "\nNumber of blanks in sentence : " << count << endl;
return 0;
}输出结果
Number of blanks in sentence : 4
在上面的程序中,在变量s中传递了一个字符串。该函数isblank()用于检查传递的字符串中的空格或空格,如以下代码片段所示。
string s = "The space between words. ";
int i = 0;
int count = 0;
while(s[i]) {
char c = s[i++];
if (isblank(c)) {
count++;
}
}热门推荐
10 朋友新年祝福语大全 简短
11 新年祝福语简短大方兔年
12 搬新家礼物祝福语简短
13 同学见面花束祝福语简短
14 五一假期祝福语幽默简短
15 离职欢送敬酒祝福语简短
16 对学弟的祝福语简短
17 考老师辞职祝福语简短
18 祝福语驱散霉运的话简短