Character handling Page 441
Page 441

UM013037-1212
Character Handling
Zilog Developer Studio II – Z8 Encore!
User Manual
417
macro puts diagnostics into programs. When it is executed, if
expression
is false (that
is, evaluates to zero), the
assert
macro writes information about the particular call that
failed (including the text of the argument, the name of the source file, and the source line
number – the latter are respectively the values of the preprocessing macros
__FILE__
and
__LINE__
) on the serial port. It then calls
abort()
, which calls
exit()
. If
expression
is true (that is, evaluates to nonzero), the
assert
macro returns no value.
On Release builds (strictly speaking, when
NDEBUG
is defined on the compile line), the
assert
macro has no effect.
Example
#include
char str[] = "COMPASS";
int main(void)
{
assert(str[0] == 'C'); // OK, nothing happens
assert(str[0] == 'B'); // Oops, something wrong here
return 0;
}
Character Handling
The <
ctype.h
> header declares several macros and functions useful for testing and map-
ping characters. In all cases, the argument is an
int
, the value of which is represented as
an
unsigned char
or equals the value of the EOF macro. If the argument has any other
value, the behavior is undefined.
Macros
Functions
The functions in this section return nonzero (true) if, and only if, the value of the argument
c conforms to that in the description of the function. The term printing character refers to
a member of a set of characters, each of which occupies one printing position on a display
device. The term control character refers to a member of a set of characters that are not
printing characters.
Character Testing
TRUE
Expands to a constant 1.
FALSE
Expands to a constant 0.
int isalnum(int c);
Tests for alphanumeric character.
int isalpha(int c);
Tests for alphabetic character.
- Z8F0131 Z8F0230 Z8F0231 Z8F0430 Z8F0431 Z8F043A Z8F0830 Z8F0831 Z8F083A Z8F1232 Z8F1233 Z8F0113 Z8F011A Z8F0123 Z8F012A Z8F0213 Z8F021A Z8F0223 Z8F022A Z8F0411 Z8F0412 Z8F0413 Z8F041A Z8F0421 Z8F0422 Z8F0423 Z8F042A Z8F0811 Z8F0812 Z8F0813 Z8F081A Z8F0821 Z8F0822 Z8F0823 Z8F082A Z8F0880 Z8F1621 Z8F1622 Z8F1680 Z8F1681 Z8F1682 Z8F2421 Z8F2422 Z8F2480 Z8F3221 Z8F3222 Z8F3281 Z8F3282 Z8F4821 Z8F4822 Z8F4823 Z8F6081 Z8F6082 Z8F6421 Z8F6422 Z8F6423 Z8F6481 Z8F6482 Z8FS021A ZMOT1AHH Z8FS040B ZMOT0BHH ZMOT0BSB Z8FMC04 Z8FMC08 Z8FMC16