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 教师闺蜜祝福语简短