wcstombs function(Convert Wide Character String to Multibyte String) in C Language – example and detail

In the C Programming Language, the wcstombs characteristic converts a wide personality string (as pointed to through pwcs) into a multibyte string (as pointed to by using s) up to n bytes in length.

Syntax

The syntax for the wcstombs function in the C Language is:

size_t wcstombs(char *s, const wchar_t *pwcs, size_t n);

Parameters or Arguments

s The array the place the transformed multibyte string will be stored. pwcs The extensive persona string to convert into a multibyte string. n The most range of bytes to store in s.

Note The wcstombs characteristic will end the conversion if a null personality is saved or if n bytes is reached.

Returns

The wcstombs function returns the wide variety of bytes stored (not including the null character). The wcstombs feature will return -1 if it encountered a character that does not correspond to a legitimate multibyte character.

Required Header

In the C Language, the required header for the wcstombs function is:

#include <stdlib.h>

Applies To

In the C Language, the wcstombs function can be used in the following versions:

ANSI/ISO 9899-1990

Similar Functions

Other C functions that are comparable to the wcstombs function:

mbstowcs function <stdlib.h>

See Also

Other C features that are noteworthy when dealing with the wcstombs function:

mblen feature mbtowc characteristic setlocale characteristic wctomb function