VOOZH about

URL: https://www.geeksforgeeks.org/cpp/wcstombs-function-in-c-stl/

⇱ wcstombs() function in C++ STL - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

wcstombs() function in C++ STL

Last Updated : 6 Jun, 2022

wcstombs() is a builtin function in C++ STL which converts a wide character string to its equivalent multibyte sequence. It is defined within the cstdlib header file of C++. Syntax

wcstombs(d, s, n)

Parameters:

  • d: It is the parameter which specifies the pointer to a character array at least n bytes long.
  • s: It is the parameter which specifies wide-character string to be converted.
  • n: It is the parameter which specifies maximum number of wide characters to be converted.

Return Value:

  • If the conversion is successful then the function returns the number of bytes (not characters) converted and written to the string, excluding the terminating null character('\0').
  • If any error is occurred then, -1 is returned.

Program 1

Output:
Number of wide character converted = 13
Multibyte Character String = GeeksforGeeks

Program 2

Output:
Number of wide character converted = 15
Multibyte Character String = 10@Hello World!
Comment
Article Tags: