
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
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.
- Related Articles
- sinh() function in C++ STL
- cosh() function in C++ STL
- atanh() function in C++ STL
- tanh() function in C++ STL
- acosh() function in C++ STL
- asinh() function in C++ STL
- acos() function in C++ STL
- atan2() function in C++ STL
- iswalnum() function in C++ STL
- iswalpha() function in C++ STL
- lldiv() function in C++ STL
- negate function in C++ STL
- iswblank() function in C++ STL
- iswcntrl() function in C++ STL
- iswdigit() function in C++ STL
