User Tools

Site Tools


c:stdlib.h:wctomb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:stdlib.h:wctomb [2024/02/16 01:04] (current)
Line 1: Line 1:
 +{{keywords>wiki library source code example reference}}
 +===== wctomb =====
 +
 +<code c>
 +    #include <stdlib.h>
 +    int wctomb(char *str, wchar_t wchar); 
 + </code>
 +===== Description =====
 +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 =====
 +<code c>
 +/* 
 + * wctomb example code
 + * http://code-reference.com/c/stdlib.h/wctomb 
 + */
 +#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;
 +}
 +
 +</code>
 +
 +==== output of wctomb example ====
 +    user@host:~/code-reference.com#  ./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