English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C / C ++mbrlen() function in

This functionmbrlen()used to obtain the length of a multibyte character. It returns the size of the multibyte character pointed to by the pointer.

Thismbrlen()C language syntax,

size_t mbrlen(const char* pointer, size_t size, mbstate_t* state);

Here,

Pointer-a pointer to the first byte of the multibyte character.

Size-the number of bytes to check.

state-the mbstate_t object pointed to

Thismbrlen()C language example,

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 result

Length of multibyte character: 1

In the above program, we are usingmbrlen()The function calculates the length of a multibyte character (in bytes).

char a[] = "s";
mbstate_t s;
int len;
len = mbrlen(a, 5, &s);