ansi-c converting char to int representable by ascii -
Hello I'm interested in the characters that are worthy of representation by the ascii table, due to this I am doing the following:
int t (char c) {return (int) c; } ... if (! (T (D)> 255)) {Dostf (); }
So I'm only interested in representable characters in the ascii table, which should be less than 256 after conversion, am I right? Thanks!
four
is an integral type in C. You can do this directly:
Four C; Specify / * C * if (C & gt; = 0 & amp; amp; c; & lt; = 127) {/ * in ASCII range} /
T isascii ()
(this is not in C standard, although it is POSIX).
In addition, you can check that is equivalent to CHAR_MAX
127. If so, you do not need to compare it with 127, because c
will not exceed the definition. Similarly, if is CHAR_MIN
0, then you compare it with 0 do not require. Both the CHAR_MIN
and CHAR_MAX
are defined in the boundaries .h
.
I think you are thinking about an integer value by filling out a char
, and so change it to a int
. But, it does not help overflow because the damage has already happened.
Comments
Post a Comment