Reference > C Reference

SwansonSoftware Home | Site Index | View With Frames

Draft Version 0.5, November 12 2003

Contents

Part 1: The C Language

  1. Metalanguage
    1. Lexical Tokens
    2. Statements
    3. Scope
    4. Comments
  2. Primitive Types - Basic Data Type Specifiers, Type Modifiers, and Type Qualifiers
  3. Objects
    1. Storage Class Specifiers
    2. Declarators
    3. Initialization
    4. External Declarations
  4. Names
  5. Expressions
    1. Expression Operators
    2. Primary Expressions
    3. Postfix Expressions
    4. Casts
    5. Constant Expressions
  6. Functions
  7. Control Structures
  8. Conversions
    1. Arithmetic
    2. Pointer
    3. Void
  9. References

Metalanguage

Next | Top of page

Lexical Tokens

The C language has six classes of tokens; they are described in the sections that follow.



Names - Identifiers

Next | Previous | Top of page

Definition

an identifier, also called a name, is one or more letters and may contain digits.

Where

Notes:

Identifiers include variables, constants, string literals, functions, typedef names, tags of enumerations, names of structures, names of unions, names of individual members of structures and unions, labels, and keywords.



Keywords

Next | Previous | Top of page

Identifiers reserved as Keywords by the language
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while

Constants

Next | Previous | Top of page



String Literals

Next | Previous | Top of page


Operators

Next | Previous | Top of page

C has the following operators:



Other Separators - White Space

Next | Previous | Top of page


Statements

Next | Previous | Top of page

  1. Labeled
  2. Expression
  3. Compound
  4. Selection
  5. Iteration
  6. Jump

Scope

Next | Previous | Top of page


Comments

Next | Previous | Top of page


Primitive Types

Next | Previous | Top of page

C has the following primitives, or type-specifiers:

  1. char - character
  2. int - integer
  3. float - floating-point
  4. double - double floating-point
  5. void - valueless
  6. struct or union
  7. enum
  8. typedef

C has four basic type modifiers:

  1. signed - use to force char objects to carry a sign, redundant otherwise
  2. unsigned
  3. long
  4. short

Type qualifiers - there are two. These control how variables of the above types may be accessed or modified.

  1. const - once initialized, const objects may not be assigned to.
  2. volatile - tells the compiler that the variable's value may change by outside processes, so it should reexamine the value each time it is referenced in an expression

These primitives are constructed from the basic types

  1. arrays
  2. functions
  3. pointers
  4. structures
  5. unions


Objects

Next | Previous | Top of page


Declarations

Next | Previous | Top of page

Identifiers are interpreted in the context of their storage class and type; declarations specify those attributes. The identifier in a declaration is called a declarator.

Declarations require at least one declarator, unless the declared type is a structure tag, a union tag, or the members of an enumeration. The declarator may be abstract - i.e. the identifier is not present. This is called a type name declaration, used when the name of a data type is required. Examples where this usage occurs include casts, function parameter declarations, and arguments for sizeof.

Storage Class Specifiers

Storage class specifiers are optional, but no more than one may apear in a declaration. Default rules apply:



Names

Next | Previous | Top of page


Expressions

Next | Previous | Top of page



Functions

Next | Previous | Top of page


Control Structures

Next | Previous | Top of page


Conversions


References


The C Programming Language, Second Edition, by Brian W. Kernighan and Dennis M. Ritchie,
Prentice Hall, NJ 1988
ISBN 0-13-110370-9

Parts of 'Characteristics of the C Language' modified from C: The Complete Reference, Third Edition, by Herbert Schildt,
Osborne McGraw-Hill, Berkeley, CA 1995
ISBN 0-07-882101-0


Top of page