Header file:
wctype.h
Synopsis:
int iswalpha(wint_t input)
Description:
Returns non-zero if input is an alphabetic character. Otherwise it returns 0.
Sample program for iswalpha 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 (iswalpha(wide_char))
printf("It is an alphabet\n");
else
printf("It is not an alphabet\n");
printf("Return value: %d\n", iswalpha(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 (iswalpha(wide_char))
printf("It is an alphabet\n");
else
printf("It is not an alphabet\n");
printf("Return value: %d\n", iswalpha(wide_char));
return 0;
}
Output:
jp@jp-VirtualBox:~/cpgms/chap4$ ./a.out
Enter your input:1
It is not an alphabet
Return value: 0
Enter your input:1
It is not an alphabet
Return value: 0
No comments:
Post a Comment