Header file:
wctype.h
Synopsis:
wctrans_t wctrans(const char *input)
Description:
The wctrans_t type represents a mapping that can map one wide character to another. Returns a mapping descriptor if the input is valid. Otherwise it returns (wctrans_t) 0.
Sample program for towctrans in C:
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
int main() {
wctrans_t a;
wint_t wide_char;
char input;
a = wctrans("digit");
printf("Enter your input:");
input = getchar();
/* mbtowc -Converts character to wide character format */
wide_char = btowc(input);
printf("Return value: %d\n", towctrans(wide_char, a));
return 0;
}
#include <wchar.h>
#include <wctype.h>
int main() {
wctrans_t a;
wint_t wide_char;
char input;
a = wctrans("digit");
printf("Enter your input:");
input = getchar();
/* mbtowc -Converts character to wide character format */
wide_char = btowc(input);
printf("Return value: %d\n", towctrans(wide_char, a));
return 0;
}
Output:
Enter your input:1
Return value: 49
Return value: 49
No comments:
Post a Comment