/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* This is an example of the function wcrtomb(char*, wchar_t, mbstate_t).  
   The wcrtomb function determines the number  of  bytes  needed  to represent
   the multibyte  character  that corresponds to the wide character given by wc.
*/
#include <wchar.h>
#include <stdlib.h>

int main() { 
    char *str;
    size_t retval;
    wchar_t c;
    mbstate_t *ps;
   
    str = "hello";
    c = 'e';
    ps = NULL;
    retval = wcrtomb(str, c, ps);
    if(retval != (size_t) -1) {
    	printf("Number of bytes needed to represent the \n");
    	printf("next character:  %d\n", retval);
    }
    else
        printf("Error\n");
}

