wctob() function in C++ helps to convert a wide character wc into a single byte, if its if its multibyte character equivalent in the initial shift state is a single byte. Since, the function uses single byte encoding, hence is used for characters from ASCII character set .
int wctob (wint_t wc);
Parameters: The above function accepts a single parameter as described below:
Return Type: The function returns a single byte representation of the wide character wc, if it corresponds to a multibyte character with a length of single byte in initial state. Otherwise, it returns EOF(End Of File).
Below programs illustrate the above function:
wc has 9 characters to be translatedto single-byte characters.
Program 2 :
In Thai UTF-8 locale: 0x61 translated to 0x61 0x3f translated to 0x3f
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between user defined function and library function in C/C++
- How to call some function before main() function in C++?
- Function Overloading vs Function Overriding in C++
- How to call function within function in C or C++
- Difference between Virtual function and Pure virtual function in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- div() function in C++
- log() function in C++
- exp() function C++
- fma() function in C++
- mbsinit() Function in C/C++
- bit_and function in C++
- mbsrtowcs() function in C/C++
- mbrlen() function in C/C++
- wcspbrk() function in C/C++
- wcsrchr() function in C/C++
- mbrtowc() function in C/C++
- wcsncat() function in C/C++
- wcsncmp() function in C/C++
- wcsrtombs() 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 firstname.lastname@example.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.