User Tools

Site Tools


c:stdlib.h:wcstombs

Differences

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

Link to this comparison view

c:stdlib.h:wcstombs [2013/01/22 22:02]
c:stdlib.h:wcstombs [2024/02/16 01:04] (current)
Line 1: Line 1:
 +{{keywords>wiki library source code example reference}}
 +===== wcstombs =====
  
 +<code c>
 +    #include <stdlib.h>
 +    size_t wcstombs(char *str, const wchar_t *pwcs, size_t n); 
 + </code>
 +===== Description =====
 +wcstombs converts a wide character string into a multibyte character string.\\
 +conversion stops after the size n is reached.\\
 +
 +The behavior of wcstombs is affected by the LC_CTYPE category of the current locale\\
 +
 +str = destination string\\
 +pwcs = pointer to wide string\\
 +n = chars to convert\\
 +
 +
 +    <setlocale.h> is for this example nessesary
 +===== wcstombs C Sourcecode Example =====
 +<code c>
 +/* 
 + * wcstombs example code
 + * http://code-reference.com/c/stdlib.h/wcstombs 
 + */
 +#include <stdio.h>
 +#include <stdlib.h>
 +#include <locale.h> /* setlocale function */
 +
 +int main(void)
 +{
 +   char str[60];
 +   wchar_t *pwcs = L"wcstombs tést äüö for code-reference.com";
 +   size_t count = 60;
 +   size_t n;
 +
 +   setlocale(LC_ALL, "");
 +   n = wcstombs(str, pwcs, count);
 +
 +   printf("%d characters from string \"%s\" converted.\n", n, str);
 +
 +   return 0;
 +
 +}
 +
 +</code>
 +
 +==== output of wcstombs example ====
 +    user@host:~$  ./wcstombs 
 +    44 characters from string "wcstombs tést äüö for code-reference.com" converted.

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War

Impressum Datenschutz