Anda di halaman 1dari 6

ike most imperative languages in the ALGOL tradition, C has facilities for structured programming and

allows lexical variable scope and recursion, while a static type system prevents many unintended
operations. In C, all executable code is contained within functions. Function parameters are always
passed by value. Pass-by-reference is simulated in C by explicitly passing pointer values.
Heterogeneous aggregate data types (struct) allow related data elements to be combined and
manipulated as a unit. C program source text is free-format, using the semicolon as a statement
terminator.

C also exhibits the following more specific characteristics:

Variables may be hidden in nested blocks


Partially weak typing; for instance, characters can be used as integers
Low-level access to computer memory by converting machine addresses to typed pointers
Function and data pointers supporting ad hoc run-time polymorphism
array indexing as a secondary notion, defined in terms of pointer arithmetic
A preprocessor for macro definition, source code file inclusion, and conditional compilation
Complex functionality such as I/O, string manipulation, and mathematical functions consistently
delegated to library routines
A relatively small set of reserved keywords
A large number of compound operators, such as +=, -=, *= and ++ etc.
C's lexical structure resembles B more than ALGOL. For example:

abram
{ ... } rather than either ALGOL 60's begin ... end or ALGOL 68's ( ... )
= is used for assignment (copying), like Fortran, rather than ALGOL's :=
== is used to test for equality (rather than .EQ. in Fortran, or = in BASIC and ALGOL)
Logical "and" and "or" are represented with && and ||; Note that the doubled-up operators don't
evaluate the right operand if the result can be determined from the left alone (short-circuit evaluation),
and are semantically distinct from the bit-wise operators & and |
[edit] Absent features
The relatively low-level nature of the language affords the programmer close control over what the
computer does, and allows special tailoring and aggressive optimization for a particular platform. This
allows the code to run efficiently on very limited hardware, such as embedded systems, and keeps the
language definition small enough to allow the programmer to understand most or all of the language,
but at the cost of some features not being included that are available in other languages:
kontrakan
No nested function definitions
No direct assignment of arrays or strings (copying can be done via standard functions; assignment of
objects having struct or union type is supported)
No automatic garbage collection
No requirement for bounds checking of arrays
No operations on whole arrays
No syntax for ranges, such as the A..B notation used in several languages
Prior to C99, no separate Boolean type (zero/nonzero is used instead)[6]
No formal closures or functions as parameters (only function and variable pointers)
No generators or coroutines; intra-thread control flow consists of nested function calls, except for the
use of the longjmp or setcontext library functions
No exception handling; standard library functions signify err

Anda mungkin juga menyukai