English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The functionisprint()
is a predefined function that checks if the passed character is printable. It returns a non-zero value, otherwise it returns zero. This function is declared in the "cctype" header file.
Thisisprint()
C ++Language syntax,
int isprint(int character);
Here,
Character-is the character to be checked.
Thisisprint()
C ++Language example,
#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; }
Output Result
value is not printable value is printable value is not printable
In the above program, three variables are declared as val1, val2and val3. Check whether each variable is printable.
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;