Copyright Digital Equipment Corp. All rights reserved.

Example

       #include <stdlib.h>
       #include <stdio.h>
       #include <wchar.h>
       #include <string.h>

       #define BUFF_SIZE 50

       main()
       {
           int i;
           wchar_t s1buf[BUFF_SIZE];
           wchar_t *status;

           /* Initialize the buffer */

           if (mbstowcs(s1buf, "abcdefghijkl lkjihgfedcba", BUFF_SIZE)

               == (size_t)-1) {

               perror("mbstowcs");
               exit(EXIT_FAILURE);
           }

        /* This program checks the wcschr function by incrementally */
        /* going through a string that ascends to the middle and    */
        /* then descends towards the end.                           */

           for (i = 0; (s1buf[i] != '\0') && (s1buf[i] != ' '); i++) {
               status = wcschr(s1buf, s1buf[i]);
               /* Check for pointer to leftmost character -test 1. */
               if (status != &s1buf[i]) {
                   printf("Error in wcschr\n");
                   exit(EXIT_FAILURE);
               }
           }

           printf("Program completed successfully\n");
       }

     When this example program is run, it produces the following
     result:

       Program completed successfully