putwchar() function in C/C++
The putwchar() function in C/C++ writes a wide character to stdout (standard output). It is defined in CPP library
Syntax :
wint_t putwchar(wchar_t ch)
Parameter : The function accepts one mandatory parameter ch which specifies the wide character to be written.
Return value : The function returns two value as below:
- This function returns the wide character represented by ch, on success
- It returns WEOF and the error indicator is set if the writing error occurs
Below programs illustrate the above function:
Program 1 :
// C++ program to illustrate // putwchar() function #include <bits/stdc++.h> using namespace std; int main() { setlocale(LC_ALL, "en_US.UTF-8"); // initiate the starting and // the last alphabet wchar_t first = L'\u05d0', last = L'\u05ea'; wcout << L"All Hebrew Alphabets : "; // print all the alphabets for (wchar_t i = first; i <= last; i++) { putwchar(i); putwchar(' '); } return 0; } |
chevron_right
filter_none
Output:
All Hebrew Alphabets : × ×? ×? ×? ×? ×? ×? ×? ×? ×? ×? ×? ×? × ×? ×? × ×¡ ×¢ ×£ פ ×¥ צ ×§ ר ש ת
Program 2 :
// C++ program to illustrate the // putwchar() function #include <bits/stdc++.h> using namespace std; int main() { wchar_t wc; // initializing the first // and last alphabets wchar_t first = 'A', last = 'Z'; wcout << L"All English Alphabets : "; // print all the alphabets from // first to the last for (wc = first; wc <= last; ++wc) { putwchar(wc); putwchar(' '); } return 0; } |
chevron_right
filter_none
Output:
All English Alphabets : A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Recommended Posts:
- Function Overloading vs Function Overriding in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- exp() function C++
- log() function in C++
- div() function in C++
- fma() function in C++
- arc function in C
- c32rtomb() function in C/C++
- strtoumax() function in C++
- iswctype() function in C/C++
- bit_and function in C++
- mbsinit() Function in C/C++
- strcmpi() function in C
- mbrlen() function in C/C++
- mbrtowc() function in C/C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



