wcstombs. McGraw-Hill The Complete Reference Fourth Edition
ಜಾಹಿರಾತು
ಜಾಹಿರಾತು
774
C + + : T h e C o m p l e t e R e f e r e n c e a function that takes a variable number of arguments is printf( ). The type va_list is defined by <cstdarg>.
The general procedure for creating a function that can take a variable number of arguments is as follows. The function must have at least one known parameter, but may have more, prior to the variable parameter list. The rightmost known parameter is called the last_parm. The name of last_parm is used as the second parameter in a call to
va_start( )
. Before any of the variable-length parameters can be accessed, the argument pointer argptr must be initialized through a call to va_start( ). After that, parameters are returned via calls to va_arg( ), with type being the type of the next parameter. Finally, once all the parameters have been read and prior to returning from the function, a call to va_end( ) must be made to ensure that the stack is properly restored. If va_end( ) is not called, a program crash is very likely.
A related function is vprintf( ).
wcstombs
#include <cstdlib> size_t wcstombs(char * out, const wchar_t *in, size_t size);
The wcstombs( ) converts the wide-character array pointed to by in into its multibyte equivalent and puts the result in the array pointed to by out. Only the first
size bytes of in are converted. Conversion stops before that if the null terminator is encountered.
If successful, wcstombs( ) returns the number of bytes converted. On failure, –1 is returned.
Related functions are wctomb( ) and mbstowcs( ).
wctomb
#include <cstdlib> int wctomb(char * out, wchar_t in);
The wctomb( ) converts the wide character in in into its multibyte equivalent and puts the result in the object pointed to by out. The array pointed to by out must be at least MB_CUR_MAX characters long.
If successful, wctomb( ) returns the number of bytes contained in the multibyte character. On failure, –1 is returned.
If out is null, then wctomb( ) returns nonzero if the multibyte character has statedependent encodings and zero if it does not.
Related functions are wcstombs( ) and mbtowc( ).
Chapter 31
The Wide-Character
Functions
775
Copyright © 2003 by The McGraw-Hill Companies. Click here for terms of use.
ಡೌನ್ಲೋಡ್ ಮಾಡಿ
ಜಾಹಿರಾತು