- 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
mbtowc function in C
The C library function int mbtowc(whcar_t *pwc, const char *str, size_t n) converts a multibyte sequence to a wide character.
Following is the declaration for mbtowc() function.
int mbtowc(whcar_t *pwc, const char *str, size_t n)
The parameters are −
pwc − This is the pointer to an object of type wchar_t.
str − This is the pointer to the first byte of a multi-byte character.
str − This is the pointer to the first byte of a multi-byte character.
n −This is the maximum number of bytes to be checked for character length.
The return values are −
If str is not NULL, the mbtowc() function returns the number of consumed bytes starting at str, or 0 if s points to a null byte, or -1 upon failure.
If str is NULL, the mbtowc() function returns non-zero if the encoding has non-trivial shift state, or zero if the encoding is stateless.
Example
#include <stdio.h> #include <stdlib.h> #include <string.h> int main () { char *str = "This is tutorialspoint.com"; wchar_t mb[100]; int len; len = mblen(NULL, MB_CUR_MAX); mbtowc(mb, str, len*strlen(str) ); wprintf(L"%ls
", mb ); return(0); }
Output
???
To Continue Learning Please Login
Login with Google