/sys$common/syshlp/HELPLIB.HLB  —  CRTL  wcswcs  Example
        #include <stdlib.h>
        #include <stdio.h>
        #include <wchar.h>

        /* This test uses wcswcs() to find the occurrence of each */
        /* subwide-character string, string1 and string2, within  */
        /* the main wide-character string, lookin.                */

        #define BUF_SIZE 50

        main()
        {
          static char lookin[] = "that this is a test was at the end";

          char string1[] = "this",
               string2[] = "the end";

          wchar_t buffer[BUF_SIZE],
                  input_buffer[BUF_SIZE];

          /* Convert lookin to wide-character format.         */
          /* Buffer and print it out.                         */

          if (mbstowcs(buffer, lookin, BUF_SIZE) == (size_t)-1) {

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

          printf("Buffer to look in: %S\n", buffer);

          /* Convert string1 to wide-character format and use */
          /* wcswcs() to locate it within buffer              */

          if (mbstowcs(input_buffer, string1, BUF_SIZE) == (size_t)-1) {

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

          printf("this: %S\n", wcswcs(buffer, input_buffer));

          /* Convert string2 to wide-character format and use */
          /* wcswcs() to locate it within buffer              */

          if (mbstowcs(input_buffer, string2, BUF_SIZE) == (size_t)-1) {

              perror("mbstowcs");
              exit(EXIT_FAILURE);
          }
          printf("the end: %S\n", wcswcs(buffer, input_buffer));

          exit(1);
        }

    Running this example produces the following results:

    Buffer to look in: that this is a test was at the end
    this: this is a test was at the end
    the end: the end
Close Help