C++ 中的 Isprint()
该函数 isprint() 是预定义函数,它检查传递的字符是否可打印。如果成功,它返回非零值,否则返回 0。该函数在“cctype”头文件中声明。
以下是 C++ 语言中 isprint() 的语法,
int isprint(int character);
此处,
字符 − 字符将被检查。
以下是在 C++ 语言中 isprint() 的一个示例,
示例
#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;
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP