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.
WCSTOMBS.CPP
                                             Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
/* WCSTOMBS.CPP illustrates the behavior of the wcstombs function
 */
 
#include <stdlib.h>
#include <stdio.h>
 
void main( void )
{
    int      i;
    char    *pmbbuf   = (char *)malloc( MB_CUR_MAX );
    wchar_t *pwcEOL   = L'\';
    wchar_t *pwchello = L"Hello, world.";
 
    printf( "Convert entire wide-character string:\" );
    i = wcstombs( pmbbuf, pwchello, MB_CUR_MAX );
    printf( "\Characters converted: %u\", i );
    printf( "\Multibyte character: %s\\", pmbbuf );
 
    printf( "Attempt to convert null character:\" );
    i = wcstombs( pmbbuf, pwcEOL, MB_CUR_MAX );
    printf( "\Characters converted: %u\", i );
    printf( "\Multibyte character: %s\\", pmbbuf );
}
                                    -♦-