/************************************************************************ * * * 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. * * * ************************************************************************/ /* wcschr_example.c */ #include #include #include #include #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) == -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"); }