User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

Q&A is closed



    #include <stdlib.h>
    int wctomb(char *str, wchar_t wchar); 


wctomb converts a wide character to a multibyte character in the string.
wctomb maximum MB_CUR_MAX sign stores in a string.
The behavior of wctomb is affected by the LC_CTYPE category of the current locale

  <setlocale.h> is for this example nessesary

wctomb C Sourcecode Example

 * wctomb example code
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main(void)
   static char string[5];
   wchar_t wchar = L'é';
   int length;
   setlocale(LC_ALL, "");
   length = wctomb(string, wchar);
   printf("number of bytes in the multibyte character : %i\n", length);
   printf("converted string : \"%s\"\n", string);
   return 0;

output of wctomb example

  user@host:~/  ./wctomb 
  number of bytes in the multibyte character : 2
  converted string : "é"

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/stdlib.h/wctomb.txt · Last modified: 2024/02/16 01:04 (external edit)

Impressum Datenschutz