DEC C
Language Reference Manual


Previous Contents Index

char*strchr(const char *s, int c);

size_t strcspn(const char *s1, const char *s2);

char*strpbrk(const char *s1, const char *s2);

char*strrchr(const char *s, int c);

size_t strspn(const char *s1, const char *s2);

char*strstr(const char *s1, const char *s2);

char*strtok(const char *s1, char *s2);

char*strerror(int errnum);

size_t strlen(const char *s);

9.14 Date and Time (<time.h>)

The <time.h> header file defines two macros, and declares four types and several functions for manipulating time and date information. Some functions process local time, which may differ from calendar time because of time zone.

Types

size_t


clock_t 
time_t 

struct tm

Macros

NULL

CLOCKS_PER_SEC

Time Conversion Functions

char*asctime(const struct tm *timeptr);

char*ctime(const time_t *timer);

struct tm*gmtime(const time_t *timer);

struct tm*localtime(const time_t *timer);

size_t strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr);

Time Manipulation Functions

clock_t clock(void);

double difftime(time_t time1, time_t time0);

time_t mktime(struct tm *timeptr);

time_t time(time_t *timer);


Appendix A
Language Syntax Summary

This section summarizes the syntax of the C language, using the syntax of the ANSI C Standard. Syntactic categories are indicated with bold type, and literal words or characters are indicated with monospaced, nonitalicized type. A colon following a syntactic category introduces its definition. Alternative definitions are listed on separate lines, or are prefaced by the words "one of." An optional element is indicated by the subscript opt. For example, the following line indicates an optional expression enclosed in braces:

{ expressionopt }

The section numbers shown in parentheses refer to the section of the American National Standard for Information Systems-Programming Language C (document number: X3.159-1989) that discusses that part of the language.

A.1.1 Lexical Grammar

A.1.1.1 Tokens

token: (§3.1)

  • keyword
  • identifier
  • constant
  • string-literal
  • operator
  • punctuator

preprocessing-token: (§3.1)

  • header-name
  • identifier
  • pp-number
  • character-constant
  • string-literal
  • operator
  • punctuator
  • each nonwhite-space character that cannot be one of the above

A.1.1.2 Keywords

keyword: (§3.1.1) one of


    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 

A.1.1.3 Identifiers

identifier: (§3.1.2)

  • nondigit
  • identifier nondigit
  • identifier digit

nondigit: §3.1.2 one of


    a  b  c  d  e  f  g  h  i  j  k  l  m 
    n  o  p  q  r  s  t  u  v  w  x  y  z 
    A  B  C  D  E  F  G  H  I  J  K  L  M 
    N  O  P  Q  R  S  T  U  V  W  X  Y  Z  _ 

digit: (§3.1.2) one of


    0  1  2  3  4  5  6  7  8  9 

A.1.1.4 Constants

constant: (§3.1.3)

  • floating-constant
  • integer-constant
  • enumeration-constant
  • character-constant

floating-constant: (§3.1.3.1)

  • fractional-constant exponent-partopt floating-suffixopt
  • digit-sequence exponent-part floating-suffixopt

fractional-constant: (§3.1.3.1)

  • digit-sequenceopt . digit-sequence
  • digit-sequence .

exponent-part: (§3.1.3.1)

  • e signopt digit-sequence
  • E signopt digit-sequence

sign: (§3.1.3.1) one of

  • + --

digit-sequence: (§3.1.3.1)

  • digit
  • digit-sequence digit

floating-suffix: (§3.1.3.1) one of

integer-constant: (§3.1.3.2)

  • decimal-constant integer-suffixopt
  • octal-constant integer-suffixopt
  • hexadecimal-constant integer-suffixopt

decimal-constant: (§3.1.3.2)

  • nonzero-digit
  • decimal-constant digit

octal-constant: (§3.1.3.2)

  • 0
  • octal-constant octal-digit

hexadecimal-constant: (§3.1.3.2)

  • 0x hexadecimal-digit
  • 0X hexadecimal-digit
  • hexadecimal-constant hexadecimal-digit

nonzero-digit: (§3.1.3.2) one of


    1  2  3  4  5  6  7  8  9 

octal-digit: (§3.1.3.2) one of


    0  1  2  3  4  5  6  7 

hexadecimal-digit: (§3.1.3.2) one of


    0  1  2  3  4  5  6  7  8  9 
    a  b  c  d  e  f 
    A  B  C  D  E  F 

integer-suffix: (§3.1.3.2)

  • unsigned-suffix long-suffixopt
  • long-suffix unsigned-suffixopt

unsigned-suffix: (§3.1.3.2) one of

long-suffix: (§3.1.3.2) one of

enumeration-constant: (§3.1.3.3)

  • identifier

character-constant: (§3.1.3.4)

  • ' c-char-sequence'
  • L' c-char-sequence'

c-char-sequence: (§3.1.3.4)

  • c-char
  • c-char-sequence c-char

c-char: (§3.1.3.4)

  • any member of the source character set except
    the single-quote ('), backslash (\), or new-line character
  • escape-sequence

escape-sequence: (§3.1.3.4)

  • simple-escape-sequence
  • octal-escape-sequence
  • hexadecimal-escape-sequence

simple-escape-sequence: (§3.1.3.4) one of


    \'  \"  \?  \\
    \a  \b  \f  \n  \r  \t  \v 

octal-escape-sequence: (§3.1.3.4)

  • \ octal-digit
  • \ octal-digit octal-digit
  • \ octal-digit octal-digit octal-digit

hexadecimal-escape-sequence:(§3.1.3.4)

  • \x hexadecimal-digit
  • hexadecimal-escape-sequence hexadecimal-digit

A.1.1.5 String Literals

string-literal: (§3.1.4)

  • "s-char-sequenceopt"
  • L"s-char-sequenceopt"


Previous Next Contents Index