HELPLIB.HLB  —  CRTL  iswctype  Example
        #include <locale.h>
        #include <wchar.h>
        #include <stdio.h>
        #include <stdlib.h>
        #include <string.h>
        #include <ctype.h>

        /* This test will set up the "upper" character class using      */
        /* wctype() and then verify whether the characters 'a' and 'A'  */
        /* are members of this class                                    */

        #include <stdlib.h>

        main()
        {

            wchar_t w_char1,
                    w_char2;
            wctype_t ret_val;

            char *char1 = "a";
            char *char2 = "A";

            ret_val = wctype("upper");

            /* Convert char1 to wide-character format - w_char1 */

            if (mbtowc(&w_char1, char1, 1) == -1) {
               perror("mbtowc");
                exit(EXIT_FAILURE);
            }

            if (iswctype((wint_t) w_char1, ret_val))
                printf("[%C] is a member of the character class upper\n",
                        w_char1);
            else
             printf("[%C] is not a member of the character class upper\n",
                      w_char1);

            /* Convert char2 to wide-character format - w_char2 */

            if (mbtowc(&w_char2, char2, 1) == -1) {
                perror("mbtowc");
                exit(EXIT_FAILURE);
            }

            if (iswctype((wint_t) w_char2, ret_val))
                printf("[%C] is a member of the character class upper\n",
                        w_char2);
            else
             printf("[%C] is not a member of the character class upper\n",
                        w_char2);
        }

      Running the example program produces the following result:

        [a] is not a member of the character class upper
        [A] is a member of the character class upper
Close Help