This blog is under construction

Sunday, 18 March 2012

iswcntrl

Header file:
    wctype.h

Synopsis:
    int iswcntrl(wint_t input)

Description:
    Returns non-zero if the given input is a control character.  Otherwise it returns 0.


Sample program for iswcntrl in C:



  #include <stdio.h>
  #include <wchar.h>
  #include <wctype.h>
  int main() {
        wint_t wide_char;
        char input;
        printf("Enter your input:");
        /* give ESC as input */
        input = getchar();

        /* mbtowc -Converts single byte to wide character format */
        wide_char = btowc(input);

        if (iswcntrl(wide_char))
                printf("It is a cntrl char\n");
        else
                printf("It is not a cntrl char\n");

        printf("Return value: %d\n", iswcntrl(wide_char));
        return 0;
  }



  Output:
  Enter your input:^[
  It is a cntrl char
  Return value: 2


No comments:

Post a Comment