
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
isprint Function in C++
The function isprint() is predefined function and it checks that the passed characters are printable or not. It returns non-zero value, if successful otherwise, zero. This function is declared in “cctype” header file.
Here is the syntax of isprint() in C++ language,
int isprint(int character);
Here,
character − The character is to be checked.
Here is an example of isprint() in 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
value is not printable value is printable value is not printable
In the above program, three variables are declared as val1, val2, and val3. Each variable is checked that variable is printable or not.
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;
Advertisements