C ++中的Isprint()
该函数isprint()是预定义函数,它检查传递的字符是否可打印。它返回非零值,否则返回零。该函数在“cctype”头文件中声明。
这是isprint()C++语言的语法,
int isprint(int character);
这里,
字符-要检查的字符。
这是isprint()C++语言的示例,
示例
#include<iostream>
#include<cctype>
using namespace std;
int main() {
int val1 = 28;
int val2 = 's';
int val3 = '\n';
if(isprint(val1))
cout << "value is printable"<< endl;
else
cout << "value is not printable"<< endl;
if(isprint(val2))
cout << "value is printable"<< endl;
else
cout << "value is not printable"<< endl;
if(isprint(val3))
cout << "value is printable"<< endl;
else
cout << "value is not printable"<< endl;
return 0;
}输出结果
value is not printable value is printable value is not printable
在上面的程序中,三个变量声明为val1,val2和val3。检查每个变量是否可打印。
if(isprint(val1)) cout << "value is printable"<< endl; else cout << "value is not printable"<< endl; if(isprint(val2)) cout << "value is printable"<< endl; else cout << "value is not printable"<< endl; if(isprint(val3)) cout << "value is printable"<< endl; else cout << "value is not printable"<< endl;
热门推荐
1 训练狗狗搜寻
2 如何训练狗狗装死
3 狗狗训练书
6 怎么训练狗狗拜年
8 狗狗训练游戏
10 狗狗嗅觉训练
11 怎么训练狗狗在笼子里不叫
12 怎么训练狗狗站立走路
13 怎么训练狗狗在马桶上
14 狗狗尿尿怎么训练
15 训练狗狗用品
16 泰迪狗狗的训练方法大小便
17 训练狗狗可以打吗
18 王曼丽的狗狗训练