Page 30 - Programming Microcontrollers in C
P. 30
Character Constants 15
return result;
}
When the file 1 is compiled, the variable able is marked as
external, and memory is allocated for its storage. When the file 2 is
compiled, the variable able is recognized to be external because of
the extern keyword, and no memory is allocated for the variable.
When the link phase of the compilation is completed, all address
references to able in file 2 will be assigned the address of able that
was defined in file 1. The example above in which the declaration
extern int able;
allowed access to able from the file 2 will not work if able had
been declared as follows in file 1:
static int able;
Character Constants
Character constants or escape sequences are data that can be stored
in memory locations designated as char. A character constant is
identified by a backslash preceding the character. We have seen the
use of the character constants ‘\n’ and ‘\t’ in previous examples.
Several of these escape sequences shown in the following table have
predefined meanings.
Escape Meaning
Sequence
\a bell character
\b backspace
\f form feed
\n new line
\r carriage return
\v vertical tab
\t horizontal tab
\? question mark
\\ back slash
\’ single quote
\” double quote
\ooo octal number
\xxx hexadecimal number