/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* This is an example of the function wcsrchr(const char_t*, wchar_t*).  
   This returns a pointer to the last occurence of the search character.
*/
#include <wchar.h>
#include <stdlib.h>

int main() { 
    wchar_t str1[100];
    wchar_t c, *retval;        
    char *line;
    int result, len;
    line = "Hello, how are you doing?";
    c = 'l'; 
    
    len = strlen(line);
    mbstowcs(str1, line, len);
    fputs("String to be searched: ", stdout);
    fputws(str1, stdout);
    printf("\nCharacter to be searched for: ");
    fputwc(c, stdout);
    printf("\n");
    retval = wcsrchr(str1,c); 
    result = retval - str1 +1;
    if(result <= 0) {
 	printf("There is no '");
        fputwc(c, stdout);
        printf("' in this string.\n");
    }
    else {
    	printf("The last occurence of '");
        fputwc(c, stdout);
        printf("' is at position: %d\n", result);
    }
}

