Reserved words:
C89 has 32 reserved words, also known as keywords, which are
the words that cannot be used for any purposes other than those for which they
are predefined:
auto
break
case
char
const
continue
default
do
double
else
enum
extern
float
for
goto
if
int
long
register
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while
C99 reserved five more words:
_Bool
_Complex
_Imaginary
inline
restrict
C11 reserved seven more words:[22]
_Alignas
_Alignof
_Atomic
_Generic
_Noreturn
_Static_assert
_Thread_local
Most of the recently reserved words begin with an underscore
followed by a capital letter, because identifiers of that form were previously
reserved by the C standard for use only by implementations. Since existing
program source code should not have been using these identifiers, it would not
be affected when C implementations started supporting these extensions to the
programming language. Some standard headers do define more convenient synonyms
for underscored identifiers. The language previously included a reserved word
called entry, but this was seldom implemented, and has now been removed as a
reserved word.[23]
Operators:
Main article: Operators in C and C++
C supports a rich set of operators, which are symbols used
within an expression to specify the manipulations to be performed while
evaluating that expression. C has operators for:
arithmetic: +, -, *, /, %
assignment: =
augmented assignment: +=, -=, *=, /=, %=, &=, |=, ^=,
<<=, >>=
bitwise logic: ~, &, |, ^
bitwise shifts: <<, >>
boolean logic: !, &&, ||
conditional evaluation: ? :
equality testing: ==, !=
calling functions: ( )
increment and decrement: ++, --
member selection: ., ->
object size: sizeof
order relations: <, <=, >, >=
reference and dereference: &, *, [ ]
sequencing: ,
subexpression grouping: ( )
Type
conversion:
C uses the operator = (used in mathematics to express
equality) to indicate assignment, following the precedent of Fortran and PL/I,
but unlike ALGOL and its derivatives. C uses the operator == to test for equality.
The similarity between these two operators (assignment and equality) may result
in the accidental use of one in place of the other, and in many cases, the
mistake does not produce an error message (although some compilers produce
warnings). For example, the conditional expression if(a==b+1) might mistakenly
be written as if(a=b+1), which will be evaluated as true if a is not zero after
the assignment.[24]
The C operator precedence is not always intuitive. For
example, the operator == binds more tightly than (is executed prior to) the
operators & (bitwise AND) and | (bitwise OR) in expressions such as x &
1 == 0, which must be written as (x & 1) == 0 if that is the coder's
intent.[25]
No comments:
Post a Comment