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;
热门推荐
10 诗词送行祝福语大全简短
11 新房开工吉日祝福语简短
12 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短