/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* This is an example of the function mbrtowc(const char*, size_t, mbstate_t).
   the mbrtowc function inspects at most n bytes beginning with the byte
   pointed  to by s to determine the number of bytes needed to complete the
   next multibyte character
*/
#include <wchar.h>
#include <stdlib.h>

int main() { 
    char *str2;
    wchar_t *str;
    size_t retval, length;
    mbstate_t *ps;
   
    str2 = "hello";
    ps = NULL;
    length = 5;
    retval = mbrtowc(str, str2, length, ps);
    if(retval != (size_t) -1) 
    	printf("Number of bytes of the next character:  %d\n", retval);
    else
        printf("error\n"); 
}

