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