- 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
mbrlen() function in C/C++
The function mbrlen() is used to get the length of multibyte character. It returns the size of multibyte character pointed by the pointer.
Here is the syntax of mbrlen() in C language,
size_t mbrlen(const char* pointer, size_t size, mbstate_t* state);
Here,
pointer − Pointer to the first byte of multibyte character.
size − Number of bytes to check.
state − Pointer to the object of mbstate_t
Here is an example of mbrlen() in C language,
Example
#include <stdio.h> #include <stdlib.h> #include <wchar.h> int main(void) { char a[] = "s"; mbstate_t s; int len; len = mbrlen(a, 5, &s); printf("Length of multibyte character : %d \n", len); }
Output
Length of multibyte character : 1
In the above program, we are calculating the length of multibyte character in bytes by using mbrlen() function.
char a[] = "s"; mbstate_t s; int len; len = mbrlen(a, 5, &s);
Advertisements