Header file:
wctype.h
Synopsis:
int iswdigit(wint_t input)
Description:
Returns non-zero if the given input is a digit. Otherwise it returns 0.
Sample program for iswdigit 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 (iswdigit(wide_char))
printf("It is a digit\n");
else
printf("It is not a digit\n");
printf("Return value: %d\n", iswdigit(wide_char));
return 0;
}
#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 (iswdigit(wide_char))
printf("It is a digit\n");
else
printf("It is not a digit\n");
printf("Return value: %d\n", iswdigit(wide_char));
return 0;
}
Output:
Enter your input:3
It is a digit
Return value: 1
It is a digit
Return value: 1
No comments:
Post a Comment