C Programming

RitchieDennis.jpg (355×342)
    C is a general-purpose computer programming language developed between  and  by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system.

     C is an imperative systems implementation language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. C was therefore useful for many applications that had formerly been coded in assembly language.
Despite its low-level capabilities, the language was designed to encourage cross-platform programming. A standards-compliant and portably written C program can be compiled for a very wide variety of computer platforms and operating systems with few changes to its source code. The language has become available on a very wide range of platforms, from embedded microcontrollers to supercomputers.

C also exhibits the following more specific characteristics:
  • A small and fixed number of keywords, including a full set of flow of control primitives: forifwhileswitch and repeat loop(implemented as do..while). There is basically one namespace, and user-defined names are not distinguished from keywords by any kind of sigil.
  • A large number of compound arithmetical and logical operators, such as +=-=*=++, etc.
  • More than one assignment may be performed in a statement.
  • Function return values may be freely discarded.
  • Static, but weakly-enforced, typing; all data has a type, but implicit conversions can be performed, for instance, characters can be used as integers.
  • Definition follows use. C has no "define" keyword; instead, a statement beginning with the name of a type is taken as a definition. There is no "function" keyword; instead, the parentheses of an argument list indicate that a function is being defined.
  • User-defined (typedef) and compound types are possible.
    • Heterogeneous aggregate data types (struct) allow related data elements to be combined and manipulated as a unit.
    • Array indexing as a secondary notion, defined in terms of pointer arithmetic. Unlike structs, arrays are not first-class objects, and must be assigned and compared with library functions. There is no "array" keyword, in use or definition; instead, square brackets indicate arrays syntactically, e.g. myarr[].
    • Enumerated types are possible with the enum keyword. They are not tagged, and are freely interconvertible with integers.
    • Strings are not a predefined data type, but usually implemented as arrays of characters, with the same need to use library functions. The length of a C string is not fixed, nor part of its type. Variable-length C-style strings are null-terminated.
  • Low-level access to computer memory by converting machine addresses to typed pointers, on which arithmetic can be performed.
  • Procedures (subroutines not returning values) are a special case of function, returning the dummy type void.
  • Functions may not be defined within the lexical scope of other functions. (Although this may be provided as an language extension by some compilers.)
  • Function and data pointers supporting ad hoc run-time polymorphism
  • A preprocessor for macro definition, source code file inclusion, and conditional compilation.
  • C is modular: files containing functions can be compiled and linked separately. Functions are exported by default from the files containing them, whereas variables are local to the file containing them unless explicitly imported.
  • Complex functionality such as I/O, string manipulation, and mathematical functions consistently delegated to library routines
  • The traditional C toolset consists of compilers, linkers, debuggers, etc invoked from the command line. Integrated development environments have also been introduced.

    See also:
    C Programs
    C programming Tutorial