- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
iswxdigit() function in C++ STL
In this article we are going to discuss the iswxdigit() function in C++, its syntax, working and its return values.
iswxdigit() function is an inbuilt function in C++ which is defined in header file. The function checks whether the passed wide character is a hexadecimal character or not. The function checks the if argument passed is hexadecimal character then return a non-zero integer value(true), else return zero(false).
A hexadecimal character is any character which is among the following −
0 1 2 3 4 5 6 7 8 9 A B C D E F
Syntax
int iswxdigit(wint_t ch);
The function accepts only one parameter, i.e. a wide character which is to be checked. The argument is casted in wint_t or WEOF.
wint_t stores an integral type of data.
Return value
The function returns an integer value, which can be either 0 (in case of false) or any non-zero value(in case of true).
Example
#include <iostream> #include <cwctype> using namespace std; int main() { wint_t a = 'A'; wint_t b = '9'; wint_t c = 'g'; iswxdigit(a)?cout<<"\nIts hexadecimal character":cout<<"\nNot hexadecimal character"; iswxdigit(b)?cout<<"\nIts hexadecimal character":cout<<"\nNot hexadecimal character"; iswxdigit(c)?cout<<"\nIts hexadecimal character":cout<<"\nNot hexadecimal character"; }
Output
If we run the above code it will generate the following output −
Its hexadecimal character Its hexadecimal character Not hexadecimal character
Example
#include <stdio.h> #include <cwchar> #include <cwctype> using namespace std; int main () { wchar_t s[] = L"ffff"; long int num; if (iswxdigit(s[0])) { num = wcstol (s,NULL,16); wprintf (L"The hexadecimal number %lx is %ld.\n",num,num); } return 0; }
Output
If we run the above code it will generate the following output −
The hexadecimal number ffff is 65535.