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 好听的元旦简短祝福语