/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* This is an example of the function wcsrtombs(char*, const wchar_t**,
                       size_t, mbstate_t). 
   The wcsrtombs function  converts  a  sequence  of  wide
   characters  from the array indirectly pointed to by src into
   a sequence of corresponding multibyte characters,  beginning
   in  the  conversion state described by the object pointed to
   by ps.   
*/
#include <wchar.h>
#include <stdlib.h>

int main() { 
    char *str1, *line;
    const wchar_t *str2;
    wchar_t str3[100];
    size_t retval, length;
    mbstate_t *ps;
    int len;
 
    line = "hello";
    len = strlen(line);
    mbstowcs(str3, line, len);
    str2 = str3;
    ps = NULL;
    length = 5;
    retval = wcsrtombs(str1, &str2,length, ps);
    if(retval != (size_t) -1) {
    	printf("Number of multibye characters successfully");
        printf(" converted: %d\n",retval);
    }
    else
	printf("Error\n");
}

