/************************************************************************ * * * Copyright Digital Equipment Corporation 1998. All rights reserved. * * * * Restricted Rights: Use, duplication, or disclosure by the U.S. * * Government is subject to restrictions as set forth in subparagraph * * (c) (1) (ii) of DFARS 252.227-7013, or in FAR 52.227-19, or in FAR * * 52.227-14 Alt. III, as applicable. * * * * This software is proprietary to and embodies the confidential * * technology of Digital Equipment Corporation. Possession, use, or * * copying of this software and media is authorized only pursuant to a * * valid written license from Digital or an authorized sublicensor. * * * ************************************************************************/ #include #include #include /* * This test uses wcswcs() to find the occurrence of each sub * wide-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) == -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) == -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) == -1) { perror("mbstowcs"); exit(EXIT_FAILURE); } printf("the end: %S\n", wcswcs(buffer, input_buffer)); exit(1); }