Header file:
wctype.h
Synopsis:
int iswgraph(wint_t input)
Description:
Returns non-zero if the given input is a graphical character. Otherwise it returns 0.
Sample program for iswgraph in C:
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
int main() {
wint_t wide_char;
char input;
printf("Enter your input:");
input = getchar();
/* mbtowc -converts single byte to wide character format */
wide_char = btowc(input);
if (iswgraph(wide_char))
printf("It is a graphical character\n");
else
printf("It is not a graphical character\n");
printf("Return value: %d\n", iswgraph(wide_char));
return 0;
}
#include <wchar.h>
#include <wctype.h>
int main() {
wint_t wide_char;
char input;
printf("Enter your input:");
input = getchar();
/* mbtowc -converts single byte to wide character format */
wide_char = btowc(input);
if (iswgraph(wide_char))
printf("It is a graphical character\n");
else
printf("It is not a graphical character\n");
printf("Return value: %d\n", iswgraph(wide_char));
return 0;
}
Output:
Enter your input:^[
It is not a graphical character
Return value: 0
It is not a graphical character
Return value: 0
jp@jp-VirtualBox:~/cpgms/chap4$ ./a.out
Enter your input:A
It is a graphical character
Return value: 3276
No comments:
Post a Comment