C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
WCTOMB.CPP
                                             Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
/* WCTOMB.CPP illustrates the behavior of the wctomb function
 */
 
#include <stdlib.h>
#include <stdio.h>
 
void main( void )
{
    int      i;
    wchar_t  wc      = L'a';
    char    *pmbnull = NULL;
    char    *pmb     = (char *)malloc( sizeof( char ) );
 
    printf( "Convert a wide character:\" );
    i = wctomb( pmb, wc );
    printf( "\Characters converted: %u\", i );
    printf( "\Multibyte character: %.1s\\", pmb );
 
    printf( "Attempt to convert when target is NULL:\" );
    i = wctomb( pmbnull, wc );
    printf( "\Characters converted: %u\", i );
    printf( "\Multibyte character: %.1s\", pmbnull );
}
                                    -♦-