putwchar() function in C/C++
Last Updated :
14 Sep, 2018
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 :
#include <bits/stdc++.h>
using namespace std;
int main()
{
setlocale (LC_ALL, "en_US.UTF-8" );
wchar_t first = L '\u05d0' , last = L '\u05ea' ;
wcout << L "All Hebrew Alphabets : " ;
for ( wchar_t i = first; i <= last; i++) {
putwchar(i);
putwchar( ' ' );
}
return 0;
}
|
Output:
All Hebrew Alphabets : × ×? ×? ×? ×? ×? ×? ×? ×? ×? ×? ×? ×? × ×? ×? × ×¡ ×¢ ×£ פ ×¥ צ ק ר ש ת
Program 2 :
#include <bits/stdc++.h>
using namespace std;
int main()
{
wchar_t wc;
wchar_t first = 'A' , last = 'Z' ;
wcout << L "All English Alphabets : " ;
for (wc = first; wc <= last; ++wc) {
putwchar(wc);
putwchar( ' ' );
}
return 0;
}
|
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
Share your thoughts in the comments
Please Login to comment...