/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/*  This is the function wcsstr(const wchar_t*, const wchar_t*).  
    This function finds the first occurence of a wide string from str2 in str1.
*/
#include <wchar.h>
#include <stdlib.h>

int main() {
    wchar_t str1[100], str2[100];
    wchar_t *retval;
    char *line, *line2;
    int len1, len2;
    line = "Today is a very fine day.";
    line2 ="is";
    len1 = strlen(line);
    len2 = strlen(line2);

    mbstowcs(str1, line, len1);
    mbstowcs(str2, line2, len2);
    retval = wcsstr(str1, str2);
    if(retval != NULL) {
    	fputs("Original: ", stdout);
    	fputws(str1, stdout);
    	fputs("\nCharacters to search for: ", stdout);
    	fputws(str2, stdout);
    	printf("\nFirst occurrence of a character ");
        printf("belonging to string2: ");
        fputws(retval,stdout);
    	fputs("\n", stdout);
    }
    else
        printf("Error\n");
}

