/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/*  This is an example of wmemchr(const wchar_t*, wchar_t, size_t).  
    This funtion finds and returns the located specified wide character 'c'.
*/
#include <wchar.h>
#include <stdlib.h>

int main() {
    int len, result;
    size_t count;        
    wchar_t *retval, str1[100], c;
    char *line;
    c='r';
    count = 20;

    line = "Hello how are you today?";
    len = strlen(line);
    mbstowcs(str1, line, len);
    retval = wmemchr(str1,c, count);
    if(retval != NULL) {
    	printf("%s\n", line);
    	result = retval - str1 +1;
    	if(result <= 0)
            printf("There is no %c in this string.\n",c);
    	else
            printf("The first '%c' is at position: %d\n", c, result);
    }
    else
        printf("Error\n");
}

