     C Cygnus libc 1.4.
    (Steve Chamberlain)   (Roland
  Pesch) Cygnus Support
   1993

     libc 1.4
  ______________________________________________________________________

  Table of Contents



  1.    (stdlib.h)
     1.1 abort -   
     1.2 abs -   
     1.3 assert -      
     1.4 atexit -       
     1.5 atof, atoff -      double  float
     1.6 atoi, atol -   
     1.7 atol -    long
     1.8 bsearch -  
     1.9 calloc -    
     1.10 div -   
     1.11 ecvt, ecvtf, fcvt, fcvtf -  double  float  
     1.12 gvcvt, gcvtf -  double  float  
     1.13 ecvtbuf, fcvtbuf - double  float  
     1.14 exit -   
     1.15 getenv -   
     1.16 labs -   
     1.17 ldiv -  y  
     1.18 malloc, realloc, free -  
     1.19 mbtowc -      
     1.20 qsort -  
     1.21 rand, srand - - 
     1.22 strtod, strtodf -   double  float
     1.23 strtol -   long
     1.24 strtoul -   unsigned long
     1.25 system -   
     1.26 wctomb -      

  2.       (ctype.h)
     2.1 isalnum - p   p
     2.2 isalpha - p 
     2.3 isascii - p  ASCII
     2.4 iscntrl - p  
     2.5 isdigit - p  p
     2.6 islower - p  
     2.7 isprint, isgraph -   
     2.8 ispunct - p  
     2.9 isspace - p  
     2.10 isupper - p  
     2.11 isxdigit - p  p
     2.12 toascii -      ASCII
     2.13 tolower -      ASCII
     2.14 toupper -      ASCII

  3.    (stdio.h)
     3.1 clearerr -      
     3.2 fclose -  
     3.3 feof -   
     3.4 ferror -     -
     3.5 fflush -     
     3.6 fgetc -      
     3.7 fgetpos -      
     3.8 fgets -       
     3.9 fiprintf -     (   )
     3.10 fopen -  
     3.11 fdopen -     
     3.12 fputc -      
     3.13 fputs -       
     3.14 fread -     
     3.15 freopen -      
     3.16 fseek -     
     3.17 fsetpos -       
     3.18 ftell -      
     3.19 fwrite -   
     3.20 getc -   ()
     3.21 getchar -   ()
     3.22 gets -    (,   fgets)
     3.23 iprintf -    (   )
     3.24 mktemp, mkstemp -     
     3.25 perror -        .
     3.26 putc -   ()
     3.27 putchar -   ()
     3.28 puts -   
     3.29 remove -   
     3.30 rename -  
     3.31 rewind -    
     3.32 setbuf -       
     3.33 setvbuf -      
     3.34 siprintf -    (   )
     3.35 printf, fprintf, sprintf -  
     3.36 scanf, fscanf, sscanf -    
     3.37 tmpfile -   
     3.38 tmpnam, tempnam -   
     3.39 vprintf, vfprintf, vsprintf -   

  4.    (string.h)
     4.1 bcmp -    
     4.2 bcopy -   
     4.3 bzero -   
     4.4 index -    
     4.5 memchr -    
     4.6 memcmp -    
     4.7 memcpy -   
     4.8 memmove -      , 
     4.9 memset -   
     4.10 rindex -     
     4.11 strcat -  
     4.12 strchr -    
     4.13 strcmp -   
     4.14 strcoll -        LC_COLLATE
     4.15 strcpy -  
     4.16 strcspn -  ,   
     4.17 strerror -     
     4.18 strlen -   
     4.19 strncat -  
     4.20 strncmp -   
     4.21 strncpy -  ,   
     4.22 strpbrk -    
     4.23 strrchr -     
     4.24 strspn -    
     4.25 strstr -  
     4.26 strtok -     
     4.27 strxfrm -  

  5. signal handling (signal.h)
     5.1 raise -  
     5.2 signal -   

  6.   (time.h)
     6.1 asctime - ppy p  py
     6.2 clock -   
     6.3 ctime -       
     6.4 difftime -   
     6.5 gmtime -      UTC
     6.6 localtime -     
     6.7 mktime -     
     6.8 strftime - p pp p p
     6.9 time -     (  )

  7.  (locale.h)
     7.1 setlocale, localeconv -    

  8.  
  9.  
     9.1    
     9.2 p    pyp 

  10.  py p
     10.1 ANSI-p , stdarg.h
        10.1.1    
        10.1.2     
        10.1.3    
     10.2  , varargs.h
        10.2.1   
        10.2.2    
        10.2.3     
        10.2.4    


  ______________________________________________________________________

  1.     (stdlib.h)


       ,   
     .  
     stdlib.h.


  1.1.  abort -   



           #include <stdlib.h>
           void abort(void);



   abort  ,  ,   
  , -     .   
    .

     abort   sigabrt (
  raise(sigabrt)).

     signal     ,
         , 
    .

  abort   - ,    
    (   ,    ;
      ,      
         
  sigabrt).

  abort   yp  .

   ANSI    abort.

     getpid  kill.



  1.2.  abs -   



             #include <stdlib.h>
             int abs(int i);



  abs   ( ) i.   ,  i
  ,    i,   i ,
      i.

    labs      long,
    int.

  y  p .

   ANSI    abs.

     pyp .


  1.3.  assert -     
  



             #include <assert.h>
             #include <stdlib.h>
             void assert(int expression);



         
  . py expression   , 
     ( ),    , 
   .

   expression  (), assert  abort, 
   , ,     :



              assertion failed: expression, file filename, line lineno



       assert   ,
   NDEBUG   .   , 
   assert  



              (void(0))



  assert   yp  .

  assert,         NDEBUG,
    ANSI.

     (   assert  )
  close, fstat, getpid, isatty, kill, lseek, read, sbrk, write.


  1.4.  atexit -       



             #include <stdlib.h>
             int atexit(void (*function)(void);



   atexit       
  ,       .
        ,
         .

      lifo-;    
          .

          
   ;    32   , atexit
   malloc       . 
    32    ,   
      ,     32  
     .

  atexit  0,       ,  -1,
     (   ,    
      malloc).

   ANSI    atexit   
         32 .

   pyp  close, fstat, isatty, lseek, read, sbrk, write.


  1.5.  atof, atoff -      double 
  float



             #include <stdlib.h>
             double atof(const char *s);
             float atoff(const char *s);



  atof      double, atoff -  float.

       s,  , 
         .  
    



              [+|-]digits[.][digits][(E|e)[+|-]digits]

       s,  
   ,       .
    ,  str ,    
          `+', `-', `.' 
  .


  atof(s)   strtod(s, NULL). atoff(s) -  strtodf(s,
  NULL).

  atof    ,   , 
  double;  0.0,      . 
        , 
      huge_val   errno  erange.
      ,   0.0  erange
    errno.

  atoff    ,   atof,   ,
    float.

   ANSI    atof. atof, atoi  atol
      ,   strod  strol,  
     .    , 
    ,  ,    
   .

     close, fstat, isatty, lseek, read, sbrk, write.


  1.6.  atoi, atol -   



             #include <stdlib.h>
             int atoi(const char *s);
             long atol(const char *s);



  atoi      int,  atol -  long.

  atoi(s)   (int)strtol(s, NULL, 10), atol(s) - 
  strtol(s, NULL, 10).

      ,   .  
      ,   0.

   ANSI    atoi.

      .



  1.7.  atol -    long



        long atol(const char *s);



  atol      long.

  atol(s)   strtol(s,NULL,10).

   ANSI    atol.

      .



  1.8.  bsearch -  



             #include <stdlib.h>
             void *bsearch(const void *key, const void *base,
                 size_t nmemb, size_t size,
                 int (*compar)(const void *, const void *));



  bsearch    ,   
   base, ,   key,   .
  nmemb -    , size -   .

         
    compar (    
  bsearch).

       (*compar),  
  ;     ,  
    , ,     
  ,      ( "" 
  ""     ).

        array,   
  key.    ,    
      .

   ANSI    bsearch.

      .



  1.9.  calloc -    



             #include <stdlib.h>
             void *calloc(size_t n, size_t s);
             void *calloc_r(void *reent, size_t <n>, <size_t> s);



  calloc   ,      n
  ,      s.
     calloc    , 
  malloc,       . (
     p   
   y malloc.)

    _calloc_r  - .
    reent -   , 
      .

          
  ,     NULL.

   ANSI    calloc.

     close, fstat, isatty, lseek, read, sbrk, write.



  1.10.  div -   



              #include <stdlib.h>
              div_t div(int n, int d);



   n  d,        div_t.

      



               typedef struct
               {
                int quot;
                int rem;
               } div_t;



    quot  ,  rem - .  
  d,  r = div(n,d),  n  r.rem + d*r.quot.

   d  0,  quot     ,   n 
      .

      long,   int,   
  ldiv.


   ANSI    div,    d 
   .

      .


  1.11.  ecvt, ecvtf, fcvt, fcvtf -  double  float 
  



              #include <stdlib.h>

              char *ecvt(double val, int chars, int *decpt, int *sgn);
              char *ecvtf(float val, int chars, int *decpt, int *sgn);

              char *fcvt(double val, int decimals, int *decpt, int *sgn);
              char *fcvtf(float val, int decimals, int *decpt, int *sgn);



  ecvt  fcvt    NULL  , 
   val  double. ecvtf  fcvtf   
     float.

  ( stdlib ecvtbuf  fcvtbuf -   ecvt  fcvt.)

     ecvt  fcvt    
   (chars  decimals).  ecvt   chars
       (   
      ,   
    ).  fcvt   decimals 
      ,     val
   .

   ecvt  fcvt      ,  
       *decpt,    -  *sgn.
     *decpt     
   ,  *sgn  0,   ,  1,
    .

        , 
    val.



          ANSI C.

   pyp  close, fstat, isatty, lseek, read, sbrk, write.



  1.12.  gvcvt, gcvtf -  double  float  



              #include <stdlib.h>

              char *gcvt(double val, int precision, char *buf);
              char *gcvtf(float val, int precision, char *buf);



  gcvt      
   NULL    *buf. gdvtf   
     float.


  gcvt    ,    printf %.precisiong -
         
    ,      
          (
    precision).

         val
  (   buf).


           ANSI C.

     close, fstat, isatty, lseek, read, sbrk, write.



  1.13.  ecvtbuf, fcvtbuf - double  float  



              #include <stdio.h>

              char *ecvtbuf(double val, int chars, int *decpt, int *sgn, char *buf);

              char *fcvtbuf(double val, int decimals, int *decpt, int *sgn, char *buf);



  ecvtbuf  fcvtbuf    NULL  ,
    val  double.

     ecvtbuf  fcvtbuf   
    (chars  decimals).  ecvtbuf  
  chars      (  
       ,   
    ).  fcvtbuf   decimals 
      ,     val
   .

   ecvtbuf  fcvtbuf      ,
         *decpt,    - 
  *sgn.    *decpt     
   ,  *sgn  0,   ,  1,
    .       buf
     ,      .

       buf  , 
    val.

   ANSI        .

     close, fstat, isatty, lseek, read, sbrk, write.



  1.14.  exit -   



              #include <stdlib.h>
              void exit(int code);



   exit    .
    code     
  :    exit_success  exit_failure  
  stdlib.h  , ,   
       .

  exit       
   .    
  ,       atexit. -,
     :    
   ,      , 
  ,    tmpfile, .

  exit   yp  pp.


   ANSI    exit,    
  exit_success  exit_failure.

     _exit.


  1.15.  getenv -   



              #include <stdlib.h>
              char *getenv(const char *name);



  getenv       ,
  (   'char **environ')  , 
      name.     
  , getenv       
  .

     ()     NULL,
      .

   ANSI    getenv,   
         .

  getenv     environ.


  1.16.  labs -   



         #include <stdlib.h>
         long labs(long i);



  labs   i. ,  i ,   
   i,   i ,    i.

   y abs p     int,  
   .

   py y p  .

   ANSI    labs.

      .



  1.17.  ldiv -  y  



              #include <stdlib.h>
              ldiv_t ldiv(long n, long d);



   n  d,        ldiv_t.

      



               typedef struct
               {
                long quot;
                long rem;
               } ldiv_t;



    quot  ,  rem - .  
  d,  r = div(n,d),  n  r.rem + d*r.quot.

   d ,  quot    ,   n,  
   .


      int,   long,   
  div.


   ANSI    ldiv,    d 
   .

      .



  1.18.  malloc, realloc, free -  



             #include <stdlib.h>
             void *malloc(size_t nbytes);
             void *realloc(void *aptr, size_t nbytes);
             void free(void *aptr);

             void *_malloc_r(void *reent, size_t nbytes);
             void *_realloc_r(void *reent, void *aptr, size_t nbytes);
             void _free_r(void *reent, void *aptr);



       .

   malloc        
   nbytes .   ,  malloc 
       .

        malloc   ,    
     ,    
  ,  realloc,        
    . realloc ,   
        .

  ,   y     ,
  y realloc  p   ,  
  y realloc  ppy    
  py y.

      py ,  p  malloc 
  realloc ( y calloc),      p
  ,  free,  p    py. 
      realloc,  0   py
  nbytes.

    _malloc_r, _realloc_r,  _free_r 
  - .   reent -
         
  .

  malloc      
  ,    ,  NULL   .  
      ,   
      malloc(0).

  realloc        NULL,
       . NULL 
      realloc(aptr,0) (    ,  
  free(aptr)).      realloc; 
         
    .

  free    .


   ANSI    malloc, realloc,  free, 
    malloc  -  , 
  nbytes p y.

     sbrk, write ( warn_vlimit).



  1.19.  mbtowc -     
  



             #include <stdlib.h>
             int mbtowc(wchar_t *pwc, const char *s, size_t n);



   ,  ANSI,  mbtowc.
    " "
    ,     .

    mbtowc py    *s  *pwc,   s 
   y NULL.

      n .

    mbtowc  0,  s - NULL;   
   1 (     ).

   ANSI    mbtowc.   
    .

  mbtowc     .


  1.20.  qsort -  



             #include <stdlib.h>
             void qsort(void *base, size_t nmemb, size_t size,
                 int (*compar)(const void *, const void *) );



  Qsort   (  base) nmemb . size
      .

        ,  
  compar. (     
  .)      ,  
       ,   base.
   (*compar)   ,   
   , ,     , 
      ( ""  ""
      ).

        ,  
  ,  ,   qsort 
       base.

  Qsort   yp  pp.


   ANSI    qsort ( 
   ).

     close, fstat, isatty, lseek, read, sbrk, write.


  1.21.  rand, srand - - 



             #include <stdlib.h>
             int rand(void);
             void srand(unsigned int seed);

             int _rand_r(void *reent);
             void _srand_r(void *reent, unsigned int seed);



  rand       ; 
     ,    
   rand    .   
    "random seed";   
      rand,    .

     random seed  srand;   
      ,  rand.   
    y   py ,
  y py pyy y ( p  p
     p)  random p  
   rand; ,     yp (pp, p
  ),   y pp y   
   "y" ,    srand  
    random seed   .

    _rand_r  _srand_r  -
  .   reent -   ,
       .

  rand   -   ;
      0  rand_max .

  srand   yp  pp

   ANSI    rand,    
  -         
    random seed     py 
  p .

  rand     .

  1.22.  strtod, strtodf -   double  float



             #include <stdlib.h>
             double strtod(const char *str, char **tail);
             float strtodf(const char *str, char **tail);

             double _strtod_r(void *reent, const char *str, char **tail);



   strtod    str,  , 
        double. 
     str,     
   ,   



        [+|-]digits[.][digits][(E|e)[+|-]digits]



    ,  str ,    
          '+', '-', '.'  
  .    ,    
     str   *tail.   
         (
       NULL)   *tail. 
        *tail,   NULL  
   tail.  strtodf   strtod 
     .

         
  .     "IEEE round-even
  rule".

    _strtod_r  - .
    reent -   , 
      .

  strtod    ,   .
       ,   0.  
        , 
      huge_val  erange   errno. 
     ,   0  erange
    errno.

     close, fstat, isatty, lseek, read, sbrk, write.


  1.23.  strtol -   long



             #include <stdlib.h>
             long strtol(const char *s, char **ptr,int base);

             long _strtol_r(void *reent,
                 const char *s, char **ptr,int base);


   strtol   *s  long.   
     :   ,  ,
    ,       
    base,      
  p  p p  NULL.   
  p       .

    base  0,     
     c:  ,  
       .   base 
   2  36,      
   ,      
   base,   .  a-z ( 
   a-z)      10  35, 
        base.  base  16,
      0x.

       
    ,      
      .    , 
     ,      
       ,   
   .

     ,   base  , 
  strtol       
  . ,   0x  
   ,     0,   
   x,    ,   
     .  base   2  36, 
  base     ,   .
          ptr,  ptr 
   NULL.

      (   
  ),       s  
  ptr ( ptr   NULL).

    _strtol_r    .
    reent -   , 
      .

  strtol   ,   .  
     0.

  strtol  long_max  long_min,    
  ,  errno  erange.


   ANSI    strtol.

      .



  1.24.  strtoul -   unsigned long



             #include <stdlib.h>
             unsigned long strtoul(const char *s, char **ptr, int base);

             unsigned long _strtoul_r(void *reent, const char *s, char **ptr, int base);


   strtoul   *s  unsigned long.  
       :   ,
   ,   ,   
        base,    
    p  p p  NULL.
     p    
    .

    base  0,     
     c (   
  ):   , ,   
    .  base   2  36,   
      ,
         base.  a-z
  (   A-Z)      10
   35,        base. 
  base  16,     0x.

       
    ,      
      .    , 
     ,      
       ,   
   .

        base  , 
  strtoul       
  . ,   0x  
   ,     0,   
   x,    ,   
     .  base   2  36, 
  base     ,   .
          ptr,  ptr 
   NULL.

      (   
  ),       s  
  ptr ( ptr   NULL).

    _strtoul_r    .
    reent -   , 
      .

  strtoul   ,   .  
     0.

  strtoul  ulong_max,    
   ,  errno  erange.

   ANSI    strtoul.

  strtoul     


  1.25.  system -   



             #include <stdlib.h>
             int system(char *s);

             int _system_r(void *reent, char *s);



  system    *s  /bin/sh    
     .

   system(NULL)    /bin/sh.

    _system_r    .
    reent -   , 
      .

  system(NULL)   ,  /bin/sh ,  0
    .

     ,  system   ,
   /bin/sh.

   ANSI    system,  
       . ANSI C 
    ,  system(NULL)    
  ,      .

  POSIX.2    system   /bin/sh.

     exit, execve, fork, wait.


  1.26.  wctomb -     
  



             #include <stdlib.h>
             int wctomb(char *s, wchar_t wchar);



   ,  ANSI,  wctomb.
    " "  
  ,     .

    wctomb py  wchar  *s,   s 
   y NULL.

    wctomb  0,  s - NULL;   
   1 (     ).

   ANSI    mbtowc.   
    .

  wctomb     .


  2.        (ctype.h)


       (    )
        (, ,
  yp, p   )     
   .

      ctype.h.



  2.1.  isalnum - p   p



             #include <ctype.h>
             int isalnum(int c);



  isalnum   ASCII      ,
        ,   -   .
         int.

        
  ,      #undef isalnum.

  isalnum   ,  c -  (a-z  a-z)
    (0-9).

   ANSI    isalnum.

      .



  2.2.  isalpha - p 



             #include <ctype.h>
             int isalpha(int c);



  isalpha   ASCII      ,
      ,   -   .  
      isacii(c)  true   
  EOF.

        
  ,      #undef isalpha.

  isalpha   ,  c -  (A-Z  a-z).

   ANSI    isalpha.

      .


  2.3.  isascii - p  ASCII



             #include <ctype.h>
             int isascii(int c);

  isascii  0,  c -  ASCII,   -   .
         int.

        
  ,      #undef isascii.

  isascii   ,    c  
  0  127 (0x00-0x7f)

   ANSI    isascii.

      .


  2.4.  iscntrl - p  



             #include <ctype.h>
             int iscntrl(int c);



  iscntrl   ASCII      ,
       ,   -  
  .      isacii(c)  true  
   EOF.

        
  ,      #undef iscntrl.

  iscntrl   ,  c -  
     (0x7f  0x00-0x1f).

   ANSI    iscntrl.

      .


  2.5.  isdigit - p  p



             #include <ctype.h>
             int isdigit(int c);



  isdigit   ASCII      ,
       ,   -   .
       isacii(c)  true  
   EOF.

        
  ,      #undef isdigit.


  isdigit   ,  c -  
  (0-9).

   ANSI    isdigit.

      .


  2.6.  islower - p  



             #include <ctype.h>
             int islower(int c);



  islower   ASCII      ,
       ,   -   .
       isacii(c)  true  
   EOF.

        
  ,      #undef islower.

  islower   ,  c -   (a-z).

   ANSI    islower.

      .


  2.7.  isprint, isgraph -   



             #include <ctype.h>
             int isprint(int c);
             int isgraph(int c);



  isprint   ASCII      ,
       ,   -   .
       isacii(c)  true  
   EOF.

        
  ,      #undef isprint.

  isprint   ,  c -  
  (0x20-0x7e), isgraph   ,   
   (0x20).

   ANSI    isprint  isgraph.

      .


  2.8.  ispunct - p  



             #include <ctype.h>
             int ispunct(int c);

  ispunct   ASCII      ,
        ,   -  
  .      isacii(c)  true  
   EOF.

        
  ,      #undef ispunct.

  ispunct   ,  c -  
   (isgraph(c) && !isalnum(c)).

   ANSI    ispunct.

      .



  2.9.  isspace - p  



             #include <ctype.h>
             int isspace(int c);



  isspace   ASCII      ,
       ,   -   .
       isacii(c)  true  
   EOF.

        
  ,      #undef isspace.

  isspace   ,  c - , tab, 
  ,  ,  tab  formfeed (0x00-0x0d,0x20).

   ANSI    isspace.

      .


  2.10.  isupper - p  



             #include <ctype.h>
             int isupper(int c);



  isupper   ASCII      ,
       ,   -   .
       isacii(c)  true  
   EOF.

        
  ,      #undef isupper.

  isupper   ,  c -   (a-z).

   ANSI    isupper.

      .


  2.11.  isxdigit - p  p



             #include <ctype.h>
             int isxdigit(int c);



  isxdigit   ASCII      ,
       ,   -  
  .      isacii(c)  true  
   EOF.

        
  ,      #undef isxdigit.

  isxdigit   ,  c - 
   (0-9, a-f  a-f).

   ANSI    isxdigit.

      .


  2.12.  toascii -      ASCII



             #include <ctype.h>
             int toascii(int c);



  toascii -  ,      
    0  127,    .

        
  ,      #undef toascii.

  toascii    0  127.

   ANSI     toascii.

      .


  2.13.  tolower -      ASCII



        #include <ctype.h>
        int tolower(int c);
        _int tolower(int c);



  tolower -  ,     
  ,     .   
    c    EOF  255.

        
  ,      #undef tolower.

  _tolower     ,   
      A-Z.

  tolower    c,     A  Z,  c
    .

  _tolower    c,     A  Z, 
        .

   ANSI    tolower. _tolower 
      .

      .



  2.14.  toupper -      ASCII



             #include <ctype.h>
             int toupper(int c);
             _int toupper(int c);



  toupper -  ,     
  ,     .  
     c    EOF  255.

        
  ,      #undef toupper.

  _toupper     ,   
      a-z.

  toupper    c,     a  z, 
  c   .

  _toupper    c,     a  z, 
        .

   ANSI    toupper. _toupper 
      .

      .

  3.     (stdio.h)


     ,     
    -.     ,
          
  string.

    -   
  ,      .

      stdio.h.

        



             _stdin_r(reent)
             _stdout_r(reent)
             _stderr_r(reent)



    stdin, stdout  stderr.  <[reent]> 
       .


  3.1.  clearerr -      



             #include <stdio.h>
             void clearerr(FILE *fp);



   stdio      ,  
    fp,      
  -,      . 
     , ,     
   .

   clearerr    .

   ferror  feof    .

  clearerr    .

   ANSI    clearerr.

      .


  3.2.  fclose -  



             #include <stdio.h>
             int fclose(FILE *fp);



    fp    ,  fclose  ,
       ( fflush(fp)).

  fclose  0,      ( ,
   fp - NULL    );   EOF.

   ANSI    fclose.

    : close, fstat, isatty, lseek, read, sbrk,
  write.



  3.3.  feof -   



             #include <stdio.h>
             int feof(FILE *fp);



  feof ,     ,    fp.

  feof  0,       ,  
     .

   ANSI    feof.

      .



  3.4.  ferror -     -



             #include <stdio.h>
             int ferror(FILE *fp);



   stdio      ,  
    fp,      
  -,      .  fer
  ror     .

   clearerr    .

  ferror  0    ;   
     .

   ANSI    ferror.

      .


  3.5.  fflush -     



        #include <stdio.h>
        int fflush(FILE *fp);



    stdio   ,  
     .

   fflush       ,
   fp.

   fp  NULL, fflush      .

  fflush  0   ,  ,  
   ;     EOF.

   ANSI    fflush.

      .


  3.6.  fgetc -      



             #include <stdio.h>
             int fgetc(FILE *fp);



   fgetc        ,
   fp.   fgetc    
  .

    -    getc.

     (  unsigned char 
    int),      
      ;    
  fgetc  EOF.

        EOF   
  ferror  feof.

   ANSI    fgetc.

    : close, fstat, isatty, lseek, read, sbrk,
  write.


  3.7.  fgetpos -      



             #include <stdio.h>
             int fgetpos(FILE *fp, fpos_t *pos);



    FILE   "",  , 
       .   stdio
         .

     fgetpos     , 
    fp; fgetpos  ,  
  ,  *pos.     , 
    fsetpos     .

     fgetpos     
    ,     ,   ftell.

  fgetpos  0    .  fgetpos 
  ,     1.  ,  
    ;  errno   
    espipe.


   ANSI    fgetpos,  
      ,   , 
          fsetpos. 
    C ftell   ,  
   fgetpos  *pos.

      .


  3.8.  fgets -       



             #include <stdio.h>
             char *fgets(char *buf, int n, FILE *fp);



     n-1   fp    .  ,
     ,   buf.   
   0.

  fgets    ,  .  
   ,  -    ,  
    -  .    
   ,   NULL.

  fgets     gets. ,  fgets
    ,     gets    ,
    .

    : close, fstat, isatty, lseek, read, sbrk,
  write.



  3.9.  fiprintf -     (   )



             #include <stdio.h>

             int fiprintf(FILE *fd, const char *format, ...);



  fiprintf -   fprintf:      
     ,       
     -   `f', `g', `g', `e'  `f' 
  .

  fiprintf      ,  
   NULL. fiprintf  ,   
   .   ,  fiprintf 
  EOF.

   ANSI     fiprintf.

    : close, fstat, isatty, lseek, read, sbrk,
  write.



  3.10.  fopen -  



             #include <stdio.h>
             FILE *fopen(const char *file, const char *mode);

             FILE *_fopen_r(void *reent, const char *file, const char *mode);



  fopen   ,    
   .      file,    
   -   mode.

    _fopen_r  - .
    reent -   , 
      .

      : ,   . *mode
         ``r'', ``w''  ``a'',
    :

     `r'
           ;    ,
                
         .


     `w'
        p     ,   
        .      y yy,   p
        p.


     `a'
        p    ,    
          .   p   , 
           y  ,  fseek
            .

  p p  p    .
    y pp   
    , p  .    
   ,   p   ,   py yy
  ``b'' (    ).

  ``rb'',  ,  "  "; ``wb''-
  "  "; ``ab'' - "  ".

       c ``b''   
  ,     ,    .

  ,     ,   
  .     ``+''  -   .
  (   ``b''  ``+'',      
  : : "rb+"  "r+b"   
     .)

   "r+" ( "rb+")      
    ,   ; "w+" ( "wb+")
     ( p    p),  
         ; "a+" ( "ab+")
      ,   -   .

  fopen    ,     
     ,      
  ,     NULL.    
    mode,  errno   EINVAL.

   ANSI    fopen.

    : close, fstat, isatty, lseek, open, read, sbrk,
  write.


  3.11.  fdopen -     



             #include <stdio.h>
             FILE *fdopen(int fd, const char *mode);
             FILE *_fdopen_r(void *reent, int fd, const char *mode);



  fdopen     file *   
    (, ,   `open'
  , ,   fopen).  mode   ,  
   fopen.

       NULL,    fopen.

   ANSI    fdopen.


  3.12.  fputc -      



             #include <stdio.h>
             int fputc(int ch, FILE *fp);



  fputc   ch  int  unsigned char,  
       ,  fp.


     p  p  (   p
  p),        
  .  py y      
  p y   , p y  .

    -    putc.

      fputc   ch.  
    EOF.       ferror(fp).

   ANSI    fputc.

    : close, fstat, isatty, lseek, read, sbrk,
  write.


  3.13.  fputs -       



             #include <stdio.h>
             int fputs(const char *s, FILE *fp);



  fputs   s (  NULL)    ,
   fp.

       0;    
  EOF.

   ANSI    fputs,     0 
    ,    .

    : close, fstat, isatty, lseek, read, sbrk,
  write.


  3.14.  fread -     



             #include <stdio.h>
             size_t fread(void *buf, size_t size, size_t count, FILE *fp);



  fread      ,  fp,
  count  (  size)  ,   buf.  fread
     count      
  .

  fread         
   .

    fread     .

   ANSI    fread.

    : close, fstat, isatty, lseek, read, sbrk,
  write.

  3.15.  freopen -     
  



             #include <stdio.h>
             FILE *freopen(const char *file, const char *mode, FILE *fp);



    fopen     
   fp ( stdin, stdout  stderr).

   fp       , freopen  
     (     ).

  file  mode    ,    fopen.

        fp.  
      ,   NULL.

   ANSI    freopen.

    : close, fstat, isatty, lseek, open, read, sbrk,
  write.


  3.16.  fseek -     



             #include <stdio.h>
             int fseek(FILE *fp, long offset, int whence)



    FILE   "",  , 
       .   stdio
         .

     fseek       fp.
   offset   ,    
    whence (    stdio.h):

     seek_set
        offset       (
          ). offset   .


     seek_cur
        offset     .  offset
           ,    .


     seek_end
        offset     . offset 
           (   ),  
        .

   ftell    .


  fseek  0    .   
   EOF.     errno 
  espipe (,    fp   
  )  einval (   ).

   ANSI    fseek.

    : close, fstat, isatty, lseek, read, sbrk,
  write.


  3.17.  fsetpos -       



             #include <stdio.h>
             int fsetpos(FILE *fp, const fpos_t *pos);



    FILE   "",  , 
       .   stdio
         .

  fsetpos     ,  fp, 
    *pos (     fgetpos).

   fseek   .

  fgetpos  0    .   
  fgetpos  1.     errno 
  espipe (,    fp   
  )  einval (   ).

   ANSI    fsetpos,   
   *pos     fgetpos .

    : close, fstat, isatty, lseek, read, sbrk,
  write.



  3.18.  ftell -      



             #include <stdio.h>
             long ftell(FILE *fp);



    FILE   "",  , 
       .   stdio
         .

    ftell     ,  fp.
        fseek 
     .

     ftell     
     ;    ,   
  fgetpos.
  ftell    ,   .  
    -1l.  ,    
  ;  errno     
   espipe.

   ANSI    ftell,    
  (   )  ,  
     fseek.    c ftell
    ,    fgetpos.

      .


  3.19.  fwrite -   



             #include <stdio.h>
             size_t fwrite(const void *buf, size_t size, size_t count, FILE *fp);



  fwrite  ,   buf, count  (
  pp size)    ,  fp. fwrite  
   count    .

  fwrite        (  )
      .

   fwrite  ,    count.  
     ,    .

   ANSI    fwrite.

    : close, fstat, isatty, lseek, read, sbrk,
  write.



  3.20.  getc -   ()



             #include <stdio.h>
             int getc(FILE *fp);



  getc -  ,   stdio.h. getc  
      ,  fp. getc  
   .

        fgetc.

     (  unsigned char 
    int),      
       ;    getc
   EOF.

        ferror  feof.


   ANSI    getc;  ,  
  ,   getc    .  getc
            ;
         ,
    ,   getc.

    : close, fstat, isatty, lseek, read, sbrk,
  write.


  3.21.  getchar -   ()



             #include <stdio.h>
             int getchar(void);

             int _getchar_r(void *reent);



  getchar -  ,   stdio.h. getchar 
       ,  fp.
  getchar    .

    _getchar_r  - .
    reent -   , 
      .

     (  unsigned char 
    int),      
       ;   
  getchar  EOF.

        ferror(stdin)  feof(stdin).

   ANSI    getchar;  ,  
  ,   getchar    .

    : close, fstat, isatty, lseek, read, sbrk,
  write.



  3.22.  gets -    (,  
  fgets)



             #include <stdio.h>

             char *gets(char *buf);

             char *_gets_r(void *reent, char *buf);



          .   
      buf.    ,  
   0.

    ,        
  buf.     internet worm  1988   
      finger-   
  ,      
  .

    _gets_r  - .
    reent -   , 
      .

  gets   ,  .  
     ,     , 
     -  .   
     ,   NULL.

    : close, fstat, isatty, lseek, read, sbrk,
  write.



  3.23.  iprintf -    (  
  )



             #include <stdio.h>

             int iprintf(const char *format, ...);



  iprintf -   printf:      
     ,       
     -   `f', `g', `g', `e'  `f' 
  .

  iprintf      ,  
   NULL. iprintf  ,   
   .   ,  iprintf 
  EOF.

   ANSI     iprintf.

    : close, fstat, isatty, lseek, read, sbrk,
  write.



  3.24.  mktemp, mkstemp -     



        #include <stdio.h>
        char *mktemp(char *path);
        int mkstemp(char *path);

        char *_mktemp_r(void *reent, char *path);
        int *_mkstemp_r(void *reent, char *path);



  mktemp  mkstemp   ,   
   . mkstemp        
   ; mktemp    .


   path    .    p
    (  y),   
   ``x''.   y   y py, 
   ``x'' yy  -  p  y.

    _mktemp_r  _mkstemp_r  -
  .   reent   
  ,      .

  mktemp   path   ,
      ,    ,
      NULL.

  mkstemp     ,  
     ,   
   -1.

   ANSI C    mktemp,  mkstemp; System V Interface
  Definition (  System V)  2  
  mktemp.

    : getpid, open, stat.



  3.25.  perror -       
  .



             #include <stdio.h>
             void perror(char *prefix);

             void _perror_r(void *reent, char *prefix);



  perror  (   )   ,
       errno.  
  NULL      prefix,    
     ,   prefix,  
      (`: ').   
    -   ,   strerror.

    _perror_r  - .
    reent -   , 
      .


  perror    .

   ANSI    perror,   
      .

    : close, fstat, isatty, lseek, read, sbrk,
  write.



  3.26.  putc -   ()



             #include <stdio.h>
             int putc(int ch, FILE *fp);



  putc -  ,   stdio.h. putc   ch
     ,  fp,     int 
  unsigned char.

         (   
  ),        
  .         
     ,    
   .

         fputc.

      putc    ch.  
     EOF.     
   ferror(fp).

   ANSI    putc;  ,  
  , putc    .  
  - putc   fp   ; 
   ,   ,    ,
   - py ,    .

    : close, fstat, isatty, lseek, read, sbrk,
  write.


  3.27.  putchar -   ()



             #include <stdio.h>
             int putchar(int ch);

             int _putchar_r(void *reent, int ch);



  putchar -  ,   stdio.h. putchar  
      ,    int 
  unsigned char.

    _putchar_r  - .
    reent -   , 
      .

      putchar    ch. 
     EOF.     
   ferror(stdin).

   ANSI    putchar;  
  ,   ,  putchar   
  .

    : close, fstat, isatty, lseek, read, sbrk,
  write.



  3.28.  puts -   



             #include <stdio.h>
             int puts(const char *s);

             int _puts_r(void *reent, const char *s);



  puts    s (    ,
   NULL)    .

    _puts_r  - .
    reent -   , 
      .

       0;    
  EOF.

   ANSI    puts,   ,  
       ,  
   .

    : close, fstat, isatty, lseek, read, sbrk,
  write.


  3.29.  remove -   



             #include <stdio.h>
             int remove(char *filename);

             int _remove_r(void *reent, char *filename);



  remove       filename   
    .  remove  p 
  ,   p    .
    p remove    p   
   y ;  yy  y p
   y    ,   p,  y 
  pp  p  .

    _remove_r  - .
    reent -   , 
      .

  remove  0      -1  
  .

   ANSI    remove,   
        .  remove 
          .

     unlink.


  3.30.  rename -  



             #include <stdio.h>
             int rename(const char *old, const char *new);

             int _rename_r(void *reent, const char *old, const char *new);



  rename     (  new)    
  *old.    rename     
   *old.

         *old   .
      p .

    _rename_r  - .
    reent -   , 
      .

   py  0 (   )  -1 (
      p).

   ANSI    rename,  p 
  y py  y .  *new  
   ,      .

    : link, unlink.


  3.31.  rewind -    



             #include <stdio.h>
             void rewind(FILE *fp);



  rewind    ( )    ,
   fp  .      
      .

  rewind  p  py.

   ANSI    rewind.

      .


  3.32.  setbuf -       



             #include <stdio.h>
             void setbuf(FILE *fp, char *buf);



  setbuf ,      ,  fp, 
    .        
   ( bufsiz,   stdio.h).  
         ,
      .

            buf.
     pp bufsiz.  NULL    buf
  ,  setbuf    .

  : setbuf      ,
    .

    -NULL buf,      
      ,  fp.

  setbuf  p  py.

   ANSI C,   System V Interface Definition ( 2)  
   setbuf.   ,    NULL  
  : SVID  2 ,    NULL
    .   
     NULL   .

    : close, fstat, isatty, lseek, read, sbrk,
  write.


  3.33.  setvbuf -      



             #include <stdio.h>
             int setvbuf(FILE *fp, char *buf,
                 int mode, size_t size);



  setvbuf      , 
  fp,      ( stdio.h)  
   mode:

     _ionbf
          ;    
            ,  fp.


     _iofbf
           :  
               
         .


     _iolbf
          :  
              ,   
             .

   size   .    yp,
  p y  y    buf.  p
  y  p NULL  py buf,  setvbuf  yp.

  pyp: setvbuf      ,
    .

    -NULL buf,      
      ,  fp.

   y y   0,  p y 
  EOF (p mode  size   y).

   ANSI C,   System V Interface Definition ( 2)  
   setvbuf.   ,    NULL  
  : SVID  2 ,    NULL
    .   
     NULL   .

         .

    : close, fstat, isatty, lseek, read, sbrk,
  write.


  3.34.  siprintf -    (  
  )



             #include <stdio.h>

             int siprintf(char *str, const char *format [, arg, ...]);



  siprintf -   sprintf:      
  ,      
   :   f, g, g, e  f  .

  siprintf      ,  
   NULL. siprintf  ,   
   .

   ANSI     siprintf.

    : close, fstat, isatty, lseek, read, sbrk,
  write.


  3.35.  printf, fprintf, sprintf -  



             #include <stdio.h>

             int printf(const char *format [, arg, ...]);
             int fprintf(FILE *fd, const char *format [, arg, ...]);
             int sprintf(char *str, const char *format [, arg, ...]);



  printf   ,    
    *format,      stdout,
     NULL.  printf  p  y
     pp. printf  ,
      .   , 
  ,    .

  fprintf  sprintf   printf,   
   : fprintf     fd,  sprintf
      str.  sprintf  
  *str  . format -    , 
    :   (  %),  
     ,   
    %. (  %     %% 
   .)    
  :



        %[flags][width][.prec][size][type]



       :

    flags

       ,  
     ,  ,  ,  ,
        .  
       (-),  (+), ,  (0)   (#). 
         .

     -   p  ,  p
        py.     y,   p
         p,  py .


     +       (   
        type)     . (    , 
            .)


               
         ,       
        ,     .    ( ) 
          (+)  ,   .


     0    type  d, i, o, u, x, X, e, E, f, g  G, 
                
        , (    py p); p 
          y.   (0)   (-) 
        ,    .   d,
        i, o, u, x  X,    prec,    (0)
        .   0   ,   
          .


     #        
        ,     :

        0   ,      .


        x       0x.


        X       0x.


        e, E   f
                ,  
                . (  
               ,    
            .)    .


        g  G
            ,  e  E,     .


          
              .



    width

     width -  ,    .
            ,  
           (*),   
       int    .  
        ,    
       ,      
     (-),      .


    prec

      ;   ,     `.'
     ().        
             
      type d, i, o, u, x  X;     
      g  G;       
     e, E,  f.        ,
             (*),  
        int   . 
          .
        ,     . 
         type,     
     .



    size

     h, l  L -   ,   
         printf   . h
        type d, i, o, u, x  X  short 
     unsigned short. h     type n
        short. , l   
     type d, i, o, u, x  X  long  unsigned long. l 
        type n    long.
      h  l    py  , 
     p  y  p. L  
      type e, E, f, g  G  long double.  L 
       py  ,  p  y 
     p.


    type

     type    ,  
       :

     %     (%)


     c   arg   


     s        NULL; 
          


     d      ;  int (  
        i)


     i      ;  int (  
        d)


     o      ;  int


     u      ;  int


     x       ( abcdef 
          9);  int


     X       ( ABCDEF 
          9);  int


     f        [-]9999.9999;  
          


     e        [-]9.9999e[+|-]999; 
           


     E    ,    e,   E  
        ;     



     g         f  e,  
             -     
             ;  
          


     G    ,    g,   E  
        ;     


     n   (   )   ;
           int


     p       .  
           unsigned long (   Lu).


     sprintf      ,  
      . printf  fprintf   
     .    printf  fprintf  EOF. 
       sprintf  .

  p ANSI C p,   p pp
    509 .

    : close, fstat, isatty, lseek, read, sbrk,
  write.



  3.36.  scanf, fscanf, sscanf -    



             #include <stdio.h>

             int scanf(const char *format [, arg, ...]);
             int fscanf(FILE *fd, const char *format [, arg, ...]);
             int sscanf(const char *str, const char *format [, arg, ...]);



  scanf      
  ,    .      
        *format.
  scanf        ,
  ,    format.     
     ,    .

         ; 
        
   .    .

  scanf    ,    
   .   gets  fgets,  
   sscanf   ,    ,
        .

  fscanf  sscanf   scanf,    :
  fscanf    ,  sscanf -  .

   *format -  ,    
   .        ,
      .

      ( ), tab (\t)    (\n).
   scanf      ,  
    (  )      .


          ASCII, 
    (%).  scanf    
     ,    ,   
   .

     scanf   pp 
        ,    
   .

     ,    
      .

        (%)  
   :



                    %[*][width][size]type



        (%).  
  :

      ;     
      


    width

        :  , 
        ,  
        .     
     width ,  scanf    ,  
          .

      py    p p width, 
         , p  p. 
     scanf p y p p.



    size h, l  L -  ,  
        scanf  
      .



                 ()
                h       d, i, o, u, x        short,
                                              short

                h       D, I, O, U, X      
                        e, f, c, s, n, p

                l       d, i, o, u, x        long,
                                              long

                l       e, f, g              double
                                              double

                l       D, I, O, U, X      
                        c, s, n, p

                L       d, i, o, u, x       long double,
                                             
                                          long double


                L              



    type ,   ,  scanf.
        :

     %     ;  p (%)
        p.


     c    .  arg: (char *arg).


     s       . 
        arg: (char arg[]).


     [pattern]
              , 
         arg.        
            
         NULL. (pattern   ,   
         ).   arg: (char *arg).


     d       arg: (int *arg).


     D       arg: (long *arg).


     o       arg: (int *arg).


     O       arg: (long *arg).


     u         arg:
        (unsigned int *arg).



     U         arg:
        (unsigned long *arg).



     x, X
             arg: (int
        *arg).


     e, f, g
               arg: (float
        *arg).


     E, F, G
               arg:
        (double *arg).


     i   ,     
         arg: (int *arg).


     i   ,     
         arg: (long *arg).


     n  p     y arg: (int
        *arg).


     p  p  y. ANSI C  p 
        p;    %p  ,   %u.
         arg: (void **arg).

     pattern  ,    ,  
         s. pattern -   ,
        ,    .
            (^),  
          , ASCII, 
       .      
     . %[0-9]    .    
          .     
      ,    .

        pattern:

     %[abcd]
        ,   a, b, c  d.


     %[^abcd]
        ,     a, b, c  d


     %[A-DW-Z]
        ,  A, B, C, D, W, X, Y, Z


     %[z-a]
        ,   z, -   a

         (   e, f, g, E, F  G )
        :

               [+/-] ddddd[.]ddd [E|e[+|-]ddd]



       ,  ddd 
  ,    .


  scanf     ,  
  ;     
   .

   scanf  p  ,  p 
  EOF.

        p,  p 0.

  scanf        
       .

  scanf        ( 
  )     :

       (*)   % 
      ;    ,  
     .


     width    (width -  ,
       ).


            
     (,  Z    .


            .

      scanf       
       ,      
             
         .

  scanf     :

           
           .


         - EOF.


      .

          ,  
        ,   
         ; scanf ,    
     .        
        ,       .

   ANSI    scanf.

     close, fstat, isatty, lseek, read, sbrk, write.


  3.37.  tmpfile -   



             #include <stdio.h>
             FILE *tmpfile(void);

             FILE *_tmpfile_r(void *reent);



     (,    ),
   ,  tmpnam.     
  wb+,           
  (  ,    
     .

    _tmpfile_r  - .
    reent -   , 
      .

  tmpfile   a y   .  
      ,   NULL,   errno 
   .

   ANSI C,   System V Interface Definition ( 2) 
   tmpfile.

     close, fstat, getpid, isatty, lseek, open,
  read, sbrk, write.

    tmpfile c  y environ.



  3.38.  tmpnam, tempnam -   



             #include <stdio.h>
             char *tmpnam(char *s);
             char *tempnam(char *dir, char *pfx);
             char *_tmpnam_r(void *reent, char *s);
             char *_tempnam_r(void *reent, char *dir, char *pfx);



         .  
        ( 
       TMP_MAX).

  tmpnam       P_tmpdir
  (  stdio.h),       
   .

   tmpnam s       
  ;   tmpnam(NULL),   
   .

  tempnam      :
   dir      ,   pfx
       .

   dir  NULL,  tempnam   
    TMPDIR;    ,  tempnam
    P_tmpdir (  stdio.h).

          , 
  NULL    tempnam    pfx.

    _tmpnam_r  _tempnam_r   
   tmpnam  tempnam .  
  reent -   ,    
   .

  y  y y    p , 
        p.     
   y,     y.

     s p tmpnam,     
     p p L_tmpnam   char.

   tmpnam,   tempnam p y   .

   ANSI    tmpnam,   
   P_tmpdir. System V Interface Definition ( 2)
    tmpnam,   tempnam.

     close, fstat, getpid, isatty, lseek, open,
  read, sbrk, write.

    y environ.



  3.39.  vprintf, vfprintf, vsprintf -   



             #include <stdio.h>
             #include <stdarg.h>
             int vprintf(const char *fmt, va_list list);
             int vfprintf(FILE *fp, const char *fmt, va_list list);
             int vsprintf(char *str, const char *fmt, va_list list);

             int _vprintf_r(void *reent, const char *fmt, va_list list);
             int _vfprintf_r(void *reent, FILE *fp, const char *fmt, va_list list);
             int _vsprintf_r(void *reent, char *str, const char *fmt, va_list list);



  vprintf, vfprintf  vsprintf   printf, fprintf 
  sprintf .      
      va_list ( va_start)
       .

       
   : vsprintf     
  ,    NULL, vprintf  vfprintf
     .    vprintf  vfprintf
   EOF.     vsprintf.

   ANSI     .

     close, fstat, isatty, lseek, read, sbrk, write.



  4.     (string.h)


           .
       string.h.


  4.1.  bcmp -    



             #include <string.h>
             int bcmp(const char *s1, const char *s2, size_t n);



    p    n  ,  p
  y s1  s2.

     memcmp.

      , p   y, 
  y s1  , p   , y
  s2.

  bcmp     .



  4.2.  bcopy -   



             #include <string.h>
             void bcopy(const char *in, char  *out, size_t n);



     n    ,   
  in,   ,  out.

       memmove.


  bcopy     .



  4.3.  bzero -   



             #include <string.h>
             void bzero(char *b, size_t length);



  bzero py y length  ,   p b.

  bzero    .

  bzero    Berkeley Software Distribution.  ANSI C, 
  System V Interface Definition ( 2)    bzero.

  bzero     .


  4.4.  index -    



             #include <string.h>
             char * index(const char *string, int c);



       c (  char) 
  ,  string (   NULL).

     strchr.

   y   ,  NULL-y, 
  c    .

  index     .



  4.5.  memchr -    



             #include <string.h>
             void *memchr(const void *src, int c, size_t length);



      ,   *src  c.  
     c,   length ;   NULL
    .

    c ,  p y  ,   
  py  length,   *src,   , 
  p NULL.

   ANSI    memchr.


  memchr     .



  4.6.  memcmp -    



             #include <string.h>
             int memcmp(const char *s1, const char *s2, size_t n);



    p    n  ,  p
  y s1  s2.

      , p   y, 
  y s1  , p   , y
  s2.

   ANSI    memcmp.

  memcmp     .


  4.7.  memcpy -   



             #include <string.h>
             void* memcpy(void *out, const void *in, size_t n);



     n    ,   in, 
   ,   out.

     ,    .

  memcpy      ,  
  out.

   ANSI    memcpy.

  memcpy     .


  4.8.  memmove -      , 

    



             #include <string.h>
             void *memmove(void *dst, const void *src, size_t length);



     length    , 
   *src   ,   *dst. memmove 
  ,    .
    dst,   .

   ANSI    memmove.

  memmove     .



  4.9.  memset -   



             #include <string.h>
             void *memset(const void *dst, int c, size_t length);



      c  unsigned char   length
    dst    .

  memset   m.

   ANSI    memset.

  memset     .



  4.10.  rindex -     



             #include <string.h>
             char * rindex(const char *string, int c);



       c (  char) 
  ,  string (   NULL).

     strrchr.

   y   ,  NULL-y,  c
     .

  rindex     .


  4.11.  strcat -  



             #include <string.h>
             char *strcat(char *dst, const char *src);



  strcat   ,  src, ( 
   NULL)   ,  dst. p  src 
   NULL   p dst.
     p  dst.

   ANSI    strcat.

  strcat     .



  4.12.  strchr -    



             #include <string.h>
             char * strchr(const char *string, int c);



       c (  char) 
  ,  string (   NULL).

   y   ,  NULL-y, 
  c    .

   ANSI    strchr.

  strchr     .


  4.13.  strcmp -   



             #include <string.h>
             int strcmp(const char *a, const char *b);



  strcmp    a    b.

   *a      *b,  strcmp
   ,  .    ,  strcmp
   .  *a     p *b,
   strcmp  ,  .

   ANSI    strcmp.

  strcmp     .


  4.14.  strcoll -       
  LC_COLLATE



             #include <string.h>
             int strcoll(const char *stra, const char * strb);



  strcoll  ,  stra  ,  strb,
   ,   LC_COLLATE.

      ,  strcoll  , 
  .    ,  strcoll  .  
     ,  strcoll  , 
  .

   ANSI    strcoll.

  strcoll     .



  4.15.  strcpy -  



             #include <string.h>
             char *strcpy(char *dst, const char *src);



  strcpy  ,  src (   NULL)
   ,  dst.

       dst.

   ANSI    strcpy.

  strcpy     .



  4.16.  strcspn -  ,   



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



        p,  s1,
  p   ,    py, y s2
  (   NULL).

  strcspn    .

   ANSI    strcspn.

  strcspn     .



  4.17.  strerror -     



        #include <string.h>
        char *strerror(int errnum);



  strerror    errnum  .  errnum
     errno.  errnum -   , 
    .

    strerror   ,   
  ,   errno.h:

     E2BIG
           


     EACCES
         


     EADV
         



     EAGAIN
          


     EBADF
          


     EBADMSG
         


     EBUSY
           


     ECHILD
         


     ECOMM
         


     EDEADLK
        


     EEXIST
         


     EDOM
         


     EFAULT
         


     EFBIG
          


     EIDRM
         


     EINTR
        


     EINVAL
         


     EIO
         /


     EISDIR
         


     ELIBACC
             


     ELIBBAD
             


     ELIBEXEC
             


     ELIBMAX
             , 
         


     ELIBSCN
         .LIB  A.OUT 


     EMFILE
           


     EMLINK
          


     EMULTIHOP
          


     ENFILE
          


     ENODEV
          



     ENOENT
            


     ENOEXEC
           


     ENOLCK
        NO LOCK


     ENOLINK
          


     ENOMEM
         


     ENOMSG
           


     ENONET
           


     ENOPKG
         


     ENOSPC
            


     ENOSR
           


     ENOSTR
         


     ENOTBLK
          


     ENOTDIR
         


     ENOTTY
          


     ENXIO
            


     EPERM
         


     EPIPE
         
     EPROTO
         


     ERANGE
          


     EREMOTE
         


     EROFS
            


     ESPIPE
         


     ESRCH
          


     ESRMNT
         srmount



     ETIME
          ioctl  


     ETXTBSY
          


     EXDEV
           

     a y  .   
   .

   ANSI    strerror,   
  ,     .

     strerror   , ANSI C
  ,    strerror  
   ;      
       .

  strerror     .



  4.18.  strlen -   



             #include <string.h>
             size_t strlen(const char *str);



   strlen    ,   *str,
        NULL.

  strlen   .

   ANSI    strlen.

  strlen     .



  4.19.  strncat -  



             #include <string.h>
             char *strncat(char *dst, const char *src, size_t length);



  strncat   ,  src, ( 
   NULL)   ,  dst. p  src 
   NULL   p dst.   NULL  
   .

   ,  NULL     
  ,       src 
   length,    NULL,     dst 
   length+1 : length   src   NULL.

     p  dst.

   ANSI    strncat.

  strncat     .


  4.20.  strncmp -   



             #include <string.h>
             int strncmp(const char *a, const char * b, size_t length);



  strncmp    a    b.

   *a      *b,  strncmp
   ,  .    ,  strncmp
   .  *a     p *b,
   strncmp  ,  .

   ANSI    strncmp.

  strncmp     .


  4.21.  strncpy -  ,   



             #include <string.h>
             char *strncpy(char *dst, const char *src, size_t length);



  strncpy    length   ,  src
  (   NULL)  ,  dst.  ,
   src   length ,   NULL 
        length.

       dst.

   ANSI    strncpy.

  strncpy     .



  4.22.  strpbrk -    



             #include <string.h>
             char *strpbrk(const char *s1, const char *s2);



        ,  s1
  -   ,  s2 (  
  NULL).

  strpbrk  y    s1 ,  NULL-
  y,    s2  s1 .

  strpbrk     .



  4.23.  strrchr -     



             #include <string.h>
             char * strrchr(const char *string, int c);



       c (  char) 
  ,  string (   NULL).

   y   ,  NULL-y,  c
     .

   ANSI    strrchr.

  strrchr     .



  4.24.  strspn -    



             #include <string.h>
             size_t strspn(const char *s1, const char *s2);



        p,  s1,
  p   ,   py, y s2 (
    NULL).

  strspn    .

   ANSI    strspn.

  strspn     .


  4.25.  strstr -  



             #include <string.h>
             char *strstr(const char *s1, const char *s2);



      ,  s1,
   ,   ,  s2
  (   NULL).

   y   ,  NULL-y,
    s2  .  s2     ,
    s1.

   ANSI    strstr.

  strstr     .



  4.26.  strtok -     



             #include <string.h>
             char *strtok(char *source, const char *delimiters)

             char *_strtok_r(void *reent, const char *source, const char *delimiters)



    strtok  ,   *source, 
   .       
    ,   *delimiters.    strtok
        ;  
    NULL,   ,    
   .   ,   ,
    p    p.

   strtok  ,     delimiters: 
       (    
     strtok).  strtok  ,
      -,    NULL,
      . ( strtok   
   *source     ,    
     ). strtok   
  *source,   NULL       ;
   source - NULL,  strtok     , 
    .  NULL  p py
    y, yy p .   
          
     -NULL    source.

  _strtok_r    ,   strtok,   
   .   reent -  
  ,      .


  strtok  y   ,  NULL, 
       .

   ANSI    strtok.

  strtok     .


  4.27.  strxfrm -  



             #include <string.h>
             size_t strxfrm(char *s1, const char *s2, size_t n);



     ,  s2,   
   ,  s1.    , 
    strcmp     , 
     ,       
  ,   strcoll,    
  .

    ,  s1,    n 
     NULL.  n  0,  s1   NULL-
  y.  ,   ,  , 
   , ,    .

    C    .


   strxfrm     ( 
    NULL).     n  ,
    ,  s1  .

   ANSI    strxfrm.

  strxfrm     .



  5.  signal handling (signal.h)


   -  ,    
  .      
    ( sys/signal.h),    
   -        , 
   .

         :

     SIGABRT
          ;  
        <<abort>>.


     SIGFPE
          ,       .


     SIGILL
            ,    
        .


     SIGINT
        ;     .


     SIGSEGV
             .


     SIGTERM
        p  pp  pp.

          - 
        ( 
  "" ),      (
  "")  p p ,  p
   -   ,     
  pp  p .



   p  y signal.h p p p:

     SIG_DFL
        y      y 
        p pp  p p p
        pp p .


     SIG_IGN
        y      y 
        pypy p pp  pp p
        .


     SIG_ERR
        p     y 
        p pp,    ,  
        p pp      -
        p.

         signal.h     sig_atomic_t.  
            ;    
        ,  p    
            p  . ( 
        p   p.)


  5.1.  raise -  



             #include <signal.h>
             int raise(int sig);

             int _raise_r(void *reent, int sig);



    sig (  p  sys/signal.h).  pp
  p  pp   py  (
    p   signal)  yp  .

    _raise_r  - .
    reent -   , 
      .

   py  0,  sig  y ,  1  p
  y.   y, p  (y  
   p  pp)   ,  
  p   sig   p py
   SIG_IGN p  .

  ANSI C    raise,   py p
   pp    .

   pyp : getpid, kill.


  5.2.  signal -   



             #include <signal.h>
             void ( * signal(int sig, void(*func)(int)))(int);

             void ( * _signal_r(void *reent, int sig, void(*func)(int)))(int);

             int raise (int sig);

             int _raise_r (void *reent, int sig);



  signal  raise    signal/raise 
   .

  signal      sig.  
     SIG_DFL (  
  )  SIG_IGN ( )   func; 
  p y func    , 
   ,    .


    ,     
  ; ,    ,
     ,    
     signal,   ,    
       .

         ,
    :   p  p
  p  volatile sig_atomic_t, -   p pp
  .

   p   py, y return (
   ),      
  ,     (    ,
    ).     
     exit  abort   .

  raise   sig  .    
   ,      .

    _signal_r  _raise_r  -
  .   reent -   
       .

         , 
   SIG_ERR:   ,    errno.

   p y    ( 
       ).

   ANSI    raise  signal.

          signal,   
      ,  
    ,    ,
        .



  6.    (time.h)


         (,  
  )   ,  .

   time.h   : clock_t  time_t   
        
    (     clock_t  
  ,    ,    
  time_t   .),  size_t  
   .

   time.h    tm  
          
   :

     tm_sec
        .


     tm_min
        .

     tm_hour
        .


     tm_mday
        .


     tm_mon
        .


     tm_year
         ( 1900).


     tm_wday
         :    p.



     tm_yday
         , p  p p.


     tm_isdst
          p:   , 
        y  p, y -    y,
        p -     .


  6.1.  asctime - ppy p  py



             #include <time.h>
             char *asctime(const struct tm *timp);

             #include <time.h>
             char *_asctime_r(const struct tm *timp, void *reent);



     timp  



              Wed Jun 15 11:38:07 1988\n\0



      ;   toasctime
   ,    .

  _asctime_r      asctime.

    reent -   , 
      .

   y  ,  
   timestamp.


   ANSI    asctime.

  asctime     .



  6.2.  clock -   



             #include <time.h>
             clock_t clock(void);



       
  ,     .  
          CLOCKS_PER_SEC.

      ,   
      ,  -
   CLOCKS_PER_SEC.     , 
   -1.

   ANSI    clock   CLOCKS_PER_SEC.

    : times.



  6.3.  ctime -       

   



             #include <time.h>
             char *ctime(time_t timp);



     timp    ( localtime) 
      



              Wed Jun 15 11:38:07 1988\n\0



  ( asctime).


   y  ,  
   timestamp.

   ANSI    ctime.

  ctime     .

  6.4.  difftime -   



             #include <time.h>
             double difftime(time_t tim1, time_t tim2);



       tim1  tim2.

   p ( )  tim2  tim1,  double.

   ANSI    difftime,  , 
  py    y   .

  difftime     .



  6.5.  gmtime -      UTC



             #include <time.h>
             struct tm *gmtime(const time_t *timep



  gmtime ,    timep     
     UTC (universal coordinated time - 
   ,    GMT, greenwich mean time), 
      
  ,  struct tm.

  gmtime      
  ,   gmtime  localtime  
  ,  -   .

        (struct
  tm).

   ANSI    gmtime.

  gmtime     .



  6.6.  localtime -     



             #include <time.h>
             struct tm *localtime(time_t *timep);



  localtime    timep   , 
      
  ,  struct tm.
  localtime      
  ,   gmtime  localtime  
  ,  -   .

  mktime -   localtime .

   y     (struct
  tm).

   ANSI    localtime.

  localtime     .


  6.7.  mktime -     



             #include <time.h>
             time_t mktime(struct tm *timp);



  mktime ,    timp - ,  
      ,  struct
  tm      .


  localtime - ,   mktime.

      timp    
   ,   -1.    
      time_t.

   ANSI    mktime.

  mktime     .



  6.8.  strftime - p pp p p



             #include <time.h>
             size_t strftime(char *s, size_t maxsize,
                 const char *format, const struct tm *timp);



  strftime     struct tm ( timp)
   ,   s      maxsize .

         format.
  *format     :   
        
  .     
     ,   % (%%  
    ).    
      ,   *timp, 
         :

     %a    .


     %A     .


     %b    .


     %B   .


     %c ,        Mon Apr 01
        13:13:13 1992


     %d  ,   .


     %H  ( 24- ),   .


     %I  ( 12- ),   .


     %j    ,    ( 001  366).


     %m  ,   .


     %M ,   .


     %P am  pm.


     %S ,   .


     %U  ,    ( 00  53; 
              ). 
         %w.



     %w  ,   ,  -.


     %W    :  %u,     
          .

        o %x ,      Mon Apr 01
        1992


     %X ,     (,   )
          13:13:13


     %y    .


     %Y  , pp  p p.


     %Z   ANSI C    , 
         ;      (%z
        ,      ).


     %%  %.


         maxsize , 
     .   , 
     -  ,   0 0 
  ,   s,    *format, 
        maxsize .


   ANSI    strftime,   
   *s,      
  maxsize .

  strftime     .



  6.9.  time -     (  )



             #include <time.h>
             time_t time(time_t *t);



  time       
   ,   time_t.    
  t,     NULL.

   -1 ,    ;  
      .

   ANSI    time.

   p p py pyp  gettimeofday.


  7.   (locale.h)


   -      (  
      ), 
        ,
    .  ANSI C     "C".

    ,    
  "C"  ; ,   , 
  . (""       
    ,    "C").



  locale.h   lconv     , 
   :

     char *decimal_point
          ,    ""
         ( ,    ). "." 
         "C".


     char *thousands_sep
         ( ),     , 
          . ""   C.


     char *grouping
             (  
        )    . 
                
         ,   0 (    NULL)
             
        . char_max ,    
        . ""   C.


     char *int_curr_symbol
           (  ),  ,  
           . ""   C.


     char *currency_symbol
          ,  . ""   C.


     char *mon_decimal_point
               .  "" 
         C.


     char *mon_thousands_sep
          thousands_sep,     .  ""
          C.



     char *mon_grouping
           grouping,  y   .  "" 
         C.


     char *positive_sign
             y p
        pp. ""   C.


     char *negative_sign
              
        . ""   C.


     char int_frac_digits
          p p pp  y 
          yp . CHAR_MAX (
        , p  p  char)   C.


     char frac_digits
          p p pp   
           p. CHAR_MAX   C.


     char p_cs_precedes
        1 ,     y p
          y  ; 0 , 
            pp . CHAR_MAX 
         C.


     char p_sep_by_space
        1 ,        
          y  y ; 0 ,
               .


     char n_cs_precedes
        1 ,     y p
          ; 0 ,   
          pp . CHAR_MAX   C.



     char n_sep_by_space
        1 ,     y p
          y y ; 0 ,  
           . char_max   C.


     char p_sign_posn
             ,
          . 0    
        ; 1       ; 2 
             ; 3    
         ; 4      .
        CHAR_MAX   C.


     char n_sign_posn
        p     ,
        p  ; y   p,  
         p_sign_posn. CHAR_MAX   C.



  7.1.  setlocale, localeconv -    



             #include <locale.h>
             char *setlocale(int category, const char *locale);
             lconv *localeconv(void);

             char *_setlocale_r(void *reent, int category, const char *locale);
             lconv *_localeconv_r(void *reent);



  setlocale  ANSI C    
       ; localeconv
      .

    ,    C 
  ; ,     .  (""
   ;       
  ,     C.)

   NULL    locale,  setlocale 
    ,    ( C  
  ).    category   locale.h
   ,   "LC_",     ,
     category  .

  localeconv     (  
  locale.h),    locale  .

  _localeconv_r  _setlocale_r    
  localeconv  setlocale .   reent -
    ,    
   .

  setlocale     ,    
    ( C   ), , 
   locale  , NULL.

  localeconv      lconv, 
         
  (       C).

   ANSI    setlocale,    C
      .

      .


  8.   


    -    ,
          
  ,       
  .     Cygnus C   
      .   ,
    ,    
  .    ,   
      .

      _reent,   reent.h.
  ,   struct _reent  ",
       ". 
  ,     ,  
   .        
    ,    
   .    ,  
   _    _r  ,     
  ,      .

  ,  fopen   , file  mode,  
   ,     
  .  _fopen_r   
  Struct_reent,      ,
       .

   ,   , 
      ,  
   _impure_ptr,    , 
      .

   ,      
  .       
      struct _reent:


  1.  p  p   
       ,   
          p.  
     y pyypy y   py  
      .


  2.  ,        
      ,    
          _impure_ptr, 
        .


      -,    .

     errno:


             _errno_r



   


             _localeconv_r  _setlocale_r



     stdio:


             _stdin_r        _stdout_r       _stderr_r



   stdio:


             _fdopen_r       _mkstemp_r       _remove_r
             _fopen_r        _mktemp_r        _rename_r
             _getchar_r      _perror_r        _tempnam_r
             _gets_r         _putchar_r       _tmpnam_r
             _iprintf_r        _puts_r          _tmpfile_r



   :


             _raise_r        _signal_r



   stdlib:



        _dtoa_r         _realloc_r      _strtoul_r
        _free_r         _srand_r        _system_r
        _malloc_r       _strtod_r
        _rand_r         _strtol_r



   string:


             _strtok_r



   system:


             _close_r        _lseek_r        _stat_r
             _fork_r         _open_r         _unlink_r
             _fstat_r        _read_r         _wait_r
             _link_r         _sbrk_r         _write_r



   time:


             _asctime_r



  9.   


   pyp C p   pyp p
  .     , 
   POSIX.1 (   IEEE 1003.1),  
      .

         
      software  " ",  ,
            (
     )    
   libc.a.


  9.1.     


         ( 
  ); ,    ,
     libc,   ,  
    .

        .  
   :      
  ,      .
          
  Errno.   ,  Cygnus C  
  Errno      errno.h,   p 
  p  pyp (p p 8).

     errno  :   
       errno    
        
    (  errno    
    errno.h).

         
   . p     errno.h,  
  p, pp :



             #include <errno.h>
             #undef errno
             extern int errno;



  pp    p y py errno.

     _exit
          pp   .   
        p ,  y    py 
        pyp (exit, system).


     close
        p .  :



                     int close(int file){
                         return -1;
                     }



     Environ
           p p   . 
        p y  y :



                     char *__env[1] = { 0 };
                     char **environ = __env;



     Execve
           .   (
          ):



                #include <errno.h>
                #undef errno
                extern int errno;
                int execve(char *name, char **argv, char **env){
                  errno=ENOMEM;
                  return -1;
                }



     fork
          .   (  
        ):



                     #include <errno.h>
                     #undef errno
                     extern int errno;
                     int fork() {
                       errno=EAGAIN;
                       return -1;
                     }



     fstat
          .    
           ,    
          .   sys/stat.h
             .



                     #include <sys/stat.h>
                     int fstat(int file, struct stat *st) {
                       st->st_mode = S_IFCHR;
                       return 0;
                     }



     getpid
        id ;     ,  
             .  
            :



                     int getpid() {
                       return 1;
                     }



     isatty
        ,     p.   
        py  ,  p 
          stdout, p y  :



                     int isatty(int file){
                        return 1;
                     }



     kill
         .  :



                     #include <errno.h>
                     #undef errno
                     extern int errno;
                     int kill(int pid, int sig){
                       errno=EINVAL;
                       return(-1);
                     }



     link
            yy . 
        :



                     #include <errno.h>
                     #undef errno
                     extern int errno;
                     int link(char *old, char *new){
                       errno=EMLINK;
                       return -1;
                     }



     lseek
           .  :



                     int lseek(int file, int ptr, int dir){
                         return 0;
                     }



     read
          .  :

                     int read(int file, char *ptr, int len){
                         return 0;
                     }



     Sbrk
           pp.  malloc   
         ,   ,   py
        . y    ; 
          end,    gnu.



                     caddr_t sbrk(int incr){
                       extern char end;           /*  */
                       static char *heap_end;
                       char *prev_heap_end;

                        (heap_end   0) {
                         heap_end = &end;
                       }
                       prev_heap_end = heap_end;
                       heap_end += incr;
                       return (caddr_t) prev_heap_end;
                     }



     Stat
        y  ( ).  :



                     int stat(char *file, struct stat *st) {
                       st->st_mode = S_IFCHR;
                       return 0;
                     }



     times
          p  y . 
        :



                     int times(struct tms *buf){
                       return -1;
                     }



     unlink
          .  :


                #include <errno.h>
                #undef errno
                extern int errno;
                int unlink(char *name){
                  errno=ENOENT;
                  return -1;
                }



     wait
          .  :



                     #include <errno.h>
                     #undef errno
                     extern int errno;
                     int wait(int *status) {
                       errno=ECHILD;
                       return -1;
                     }



     write
           . pyp libc y y
        pypy     ,  stdout -   
        p  , pp,   p 
        , y  y p write 
         .  y   - 
        pp;    pyp writechar ( p;
              p  pp,
         p py)  p y
        .



                     int write(int file, char *ptr, int len){
                         int todo;

                          (todo = 0; todo < len; todo++) {
                             writechar(*ptr++);
                         }
                         return len;
                     }



  9.2.  p    pyp 


  y  pyp y pyp py
  , p py p ,  libc.a p
  pyp- (pp, p  p fork -
  _fork_r).  pyp- y py p
   pyp   ,  p 
   y  ppp  
   (p y 8)
     _open_r
        p  p open.  p   
         ,  p errno.



                     int _open_r(void *reent,
                         const char *file, int flags, int mode);



     _close_r
        p  p close.  p  
          ,  p errno.



                     int _close_r(void *reent, int fd);



     _lseek_r
        p  p lseek.  p  
          ,  p errno.



                     off_t _lseek_r(void *reent,
                         int fd, off_t pos, int whence);



     _read_r
        p  p read.  p   
         ,  p errno.



                     long _read_r(void *reent,
                         int fd, void *buf, size_t cnt);



     _write_r
        p  p write.  p  
          ,  p errno.



                     long _write_r(void *reent,
                         int fd, const void *buf, size_t cnt);



     _fork_r
        p  p fork.  p   
         ,  p errno.



                     int _fork_r(void *reent);



     _wait_r
        p  p wait.  p   
         ,  p errno.



                     int _wait_r(void *reent, int *status);



     _stat_r
        p  p stat.  p   
         ,  p errno.



                     int _stat_r(void *reent,
                         const char *file, struct stat *pstat);



     _fstat_r
        p  p fstat.  p  
          ,  p errno.



                     int _fstat_r(void *reent,
                         int fd, struct stat *pstat);



     _link_r
        p  p link.  p   
         ,  p errno.



                     int _link_r(void *reent,
                         const char *old, const char *new);



     _unlink_r
        p  p unlink.  p  
          ,  p errno.



                     int _unlink_r(void *reent, const char *file);



     _sbrk_r
        p  p sbrk.  p   
         ,  p errno.



                     char *_sbrk_r(void *reent, size_t incr);



  10.   py p


   y  printf   ,  
   p  ,    
  .  p   p 
  py, p  p-p  stdarg.h (
    ANSI C)   varargs.h (  
  p ANSI C yp p).


  10.1.  ANSI-p , stdarg.h



   ANSI C y  p   ,  
   pp    (...).   
           ;
        .

   ANSI     (va_start, va_arg  va_end)
       . stdarg.h 
        
  :    va_list.


  10.1.1.     



             #include <stdarg.h>
             void va_start0(va_list ap, rightmost);



      ap  va_start
  ,  va_arg     . rightmost - 
         (
    ... ,     
   ,  ANSI C). va_start 
     ,   
   (, ,      ).

  va_start    .

   ANSI    va_start.


  10.1.2.      



             #include <stdarg.h>
             type va_arg(va_list ap, type);



  va_arg      
    ap (     
   va_start).       
  type.

    va_list ap    ,  va_arg
    ,        
    ;       va_arg 
     . ANSI C    
           
  .

   yy  pp  y py;
     p  py ( -
  py ,  p   py)  
   p .

  va_arg   ,   type.

   ANSI    va_arg.


  10.1.3.     



             #include <stdarg.h>
             void va_end(va_list ap);



   va_end     
     ap.

  va_end    .

   ANSI    va_end.



  10.2.   , varargs.h


    c   ANSI C,    
      , 
     varargs.h.       ANSI,
       .  , 
   c       
  ,      
       .

     stdarg.h,  va_list    ,
     .


  10.2.1.    



             #include <varargs.h>
             function(va_alist)
             va_dcl



     varargs.h    
      p va_alist     
   va_dcl  .      
  va_dcl.

        ,   
    .

  va_alist  va_dcl -    
      ANSI C.



  10.2.2.     



             #include <varargs.h>
             va_list ap;
             va_start(ap);



      varargs.h va_start   
  ap       . ap
     va_alist.

  va_start    .

   ANSI    va_start,  
  ;  ANSI    ,  ap.

  10.2.3.      



             #include <varargs.h>
             type va_arg(va_list ap, type);



  va_arg      
    ap (     va_start).
        type.

  va_arg   ,   type.

  va_arg,   varargs.h      
  ,     stdarg.h,  ANSI C.


  10.2.4.     



             #include <varargs.h>
             void va_end(va_list ap);



   va_end     
     ap.

  va_end    .

  va_end,   varargs.h      
  ,     stdarg.h,  ANSI C.



