

                           1. .

       㪮⢮ ᮤন ᠭ   㭪権
 ⥪  Borland  C++,    ६    ⨯,   ⠪
 ਬ ணࠬ    樨   ᯮ짮   設⢠
 㭪権, ६  ⨯.

      ᫨   ⮫쪮  稭 ணࠬ஢  몥 "C" 
 "C++", ,  ᫨  㦭 ଠ  ᮤন 㬥樨
  Borland C++,    ᭠砫    ன 
 ⮬ "Getting  Started",    뢠   "Navigating   in
 Borland  C++  manuals".

        ⪮ ᠭ   㪮⢠:

       1:  㭪 main.   ⮩  㦤 㬥
 㭪樨 main,      ᮤঠ騥    ᨬ    ᪨஢,
 ਢ ᪮쪮  ਬ஢  ணࠬ   ⪠ ଠ,
  ᮣ襭    맮  몠  Pascal.  ஬   ⮣
 ᠭ 頥 㭪樥 main 祭.

       2: ⥪ Borland C++. ᠭ  
 㭪権 Borland C++  䠢⭮  浪.      㭪樨
 㪠   ᫥  ଠ:  ᨭ⠪,  砥  䠩,
 ⪮ ᠭ ⢨,  頥 祭, ७ᨬ
  㭪樨    ᯨ᪮  뫮  易   㭪樨 
 ਬ ᯮ짮  㭪樨.

       3:      ६.   ਢ    ᠭ
   ६  Borland C++.    ᯮ짮 
 ६,  ⮡ ᢮ ᥡ  ࠡ  ணࠬ஢
   ६  (,  ६,  ᮮ饭  訡,  ࠧ
 ⥪  ..).

      2. 㬥  ᠬ  㭪, 童 ᮢ.

      ।   㭪樨 -  童    祭  
  2.  ਢ ᯨ᮪ ᮢ  㭪権 - 童 ᮢ
   ࠭,    ᠭ.

 
                                   ࠭
 
 abs          㭪 - 童       11
 acos         㭪 - 童       16
 arg          㭪 - 童       19
 asin         㭪 - 童       21
 atan         㭪 - 童       23
 bcd                                32
 complex                            69
 conj         㭪 - 童       71
 cos          㭪 - 童       73
 cosh         㭪 - 童       74
 exp          㭪 - 童       115
 imag         㭪 - 童       263
 log          㭪 - 童       306
 log10        㭪 - 童       307
 norm         㭪 - 童       335
 pow          㭪 - 童       356
 polar        㭪 - 童       354
 real         㭪 - 童       387
 sin          㭪 - 童       469
 sinh         㭪 - 童       470
 sqrt         㭪 - 童       479
 tan          㭪 - 童       515
 tanh         㭪 - 童       516
 

      ਬ砭: ,  ᯮ     㪮⢥  
 ᮮ⢥⢨  ᠭ, ਢ  "Getting Started".



  1
 
 㭪 main.
 
       ணࠬ        C++    㭪 main;
 祬  ,     .    ணࠬ
    砫 䠩,   .  ᨬ
    室  ᫥饥:

                    㬥 㭪樨 "main".

      ᪠ 楤 Borland C++ 뫠 㭪樨 main 
 ࠬ (㬥): argc, argv  env.

      - argc,  楫,  -    ᫮ 㬥⮢  ப,
        뫠 㭪樨 main,

      - argv  ᨢ 㪠⥫  ப (char * []).

          ᨥ  DOS   3.x            argv[0]
         ।    ᪠ ணࠬ.

         ࠡ   ࠭ ﬨ DOS argv 㪠뢠
          㫥 ப ("").

        argv[1] 㪠뢠   ᫥  ணࠬ ப
          ப.

        argv[2] 㪠뢠   ᫥  ணࠬ ப
          ப.

        argv[argc-1] 㪠뢠  ᫥ 㬥, 뫠
         㭪樨 main.

        argv[argc] ᮤন NULL.

      - env ⠪  ᨢ 㪠⥫  ப.  
         env[] ᮤন ப  ENVVAR=祭.

        ENVVAR -   ६ ।, ⨯ PATH  87.

        <祭>   祭    ६  㦥,
         ਬ C:\DOS;C:\TOOLS ( PATH)  YES ( 87).

      ⨬, ,    ᫨  뢠   
 㬥⮢,     뢠    ⠪  浪:  argc,
 argv, env. ਬ, ⨬ ᫥騥  㬥⮢:

     main()
     main(int argc)         /* ⨬   祭  */
     main(int argc, char *argv[])
     main(int argc, char *argv[], char *env[])

       main(int argc)  祭  㤮  ⥬,    
 ⢮ ࠬ஢,    㯠   ᠬ.

      㬥 env  ᥣ  㯥  १  ६
 environ.  ᠭ ६  environ  (    3)  
 㭪樨 putenv  getenv (  2).

      ࠬ argc   argv ⠪ 㯭 १ ६_argc
  _argv.

        ਬ ணࠬ, ᯮ饩 argc, argv  env.

       ਬ  ணࠬ   ARGS.EXE,      
 ⥩訩    ᯮ짮  㬥⮢,  뫠 㭪樨
 main.

     /* ணࠬ ARGS.C */

 #include <stdio.h>
 #include <stdlib.h>

 void main(int argc, char *argv[], char *env[])
 {
 int i;

 printf("祭 argc ࠢ %d \n\n",argc);
 printf("  ப ᮤন %d ࠬ஢ \n\n",argc);

 for (i=0; i<=argc; i++)
    printf(" argv[%d]: %s\n",i,argv[i]);

 printf("। ᮤন ᫥騥 ப:\n");

 for (i=0; env[i] != NULL; i++)
    printf(" env[%d]: %s\n",i,env[i]);

 return 0;
 }

      ।,       ᪠  ணࠬ  ARGS.EXE  
 ᫥饩  ப:

 C:> args first_arg "arg with blanks" 3 4 "last but one" stop!

      ⨬,       ᫠  㬥     ஡,
 稢         窨,        ਬ
 "argument with  blanks"    "last  but  one"    ਬ  맮
 ணࠬ.

       १   ࠡ   ணࠬ        ਬ୮
 ᫥饥:

     祭 argc ࠢ 7

       ப ᮤন 7 ࠬ஢

        argv[0]: c:\turboc\testargs.exe
        argv[1]: first_arg
        argv[2]: arg with blank
        argv[3]: 3
        argv[4]: 4
        argv[5]: last but one
        argv[6]: stop!

     । ᮤন ᫥騥 ப:

        env[0]: COMSPEC=C:\COMMAND.COM
        env[1]: PROMPT=$p $g
        env[2]: PATH=C:\SPRINT;C:\DOS;C:\BC

      ᨬ쭠        ப,   뫠
 㭪樨  main ( ஡   ᠬ ணࠬ),   
 ॢ 128 ᨬ;  ࠭祭 DOS.

              ᪨஢   ப

      㬥    ப      ᮤঠ    ᨬ
 ᪨஢.    ⮬          
 䠩,   ᮢ  㬥⮬ ⠪,     ,
 ਬ,      DOS  copy.    ᯮ짮  ᨬ
 ᪨஢   室      뢠   襩   ணࠬ
 ।஬    痢   ᮥ         ꥪ   䠩
 WILDARGS.OBJ,  ⠢  Borland C++.

      ᫨ 䠩 WILDARGS.OBJ ᮥ  襩 ணࠬ,  
    ப ᯮ짮 㬥 ⨯ "*.*". 
 ⮬   䠩,  室   ᪥,   
 ᨢ argv.  ᨬ ࠧ ᨢ argv  ⮫쪮 
 ꥬ ᪮  .

      ᫨       諮  室  䠩,  
 㬥  ।    ⮬  ,          ࠭ 
   ப.  (..  㭪樨   main   ।   ப,
 ᮤঠ ᨬ ᪨஢).

      㬥, 祭        窨  ("..."),  
 .

      ਬ. 騥       䠩   ARGS.C   
 뢠        㫥  WILDARGS.OBJ,    ⥬  ᪠
 稢 ணࠬ ARGS.EXE:

     bcc args wildarg.obj

     args C:\BORLANDC\INCLUDE\*.H  "*.C"

       ᪥ ARGS.EXE  㬥      
  䠩    ७  H  ४ਨ Borland C++ INCLUDE.
 ⬥⨬,    ப        (  ਬ
 C:\TC\INCLUDE\ALLOC.H).  㬥  *.C  ,  ..  
 祭  窨.

      ᫨  ࠡ⠥  ⥣஢ 㦥 (BC.EXE),  
     㦭  㪠      ஥  䠩 ஥,
   ᮤঠ ᫥騥 ப:

     ARGS
     WILDARGS.OBJ

      ⥬      "Run/Arguments" ᫥ ⠭
 ࠬ  ப.

      砭. ᫨    ,   ⮡   ࠡ⪠   ᨬ
 ᪨஢   ந室   ᥣ,   ..  ⮡  WILDARGS.OBJ
 ⮬᪨  ᮥ  ।஬   痢,      
 ஢  ⠭ ⥪ C?.LIB,   
 䠩 WILDARGS.OBJ.   ⮣ 㤠   ⥪  SETARGV  
  WILDARGS.    ᤥ   ᫥ 
 ( ࠧ㬥,   ⠭  ⥪    WILDARGS.OBJ
 ᮤঠ  ⥪饩 ४ਨ):

      TLIB ᠭ   7 "⨫" 㬥 "User's Guide".
                                                     
      tlib cs -setargv +wildargs
      tlib cc -setargv +wildargs
      tlib cm -setargv +wildargs
      tlib cl -setargv +wildargs
      tlib ch -setargv +wildargs


     ᯮ짮   -p  (襭    맮
                         몠 ᪠).

      ᫨     ணࠬ,  ᯮ ᮣ襭
  맮 몠 ᪠ (⠫쭮 ᠭ   9 "Interfacing
 with   assembly  languige",  "Programmer's  Guide"),    
 ,  㭪 main      㭪
 .     ᤥ    祢 ᫮ cdecl ਬ୮
 ⠪:
 
     cdecl main(int argc, char *argv[], char *env[])

              祭, 頥 㭪樥 main.

      㭪 main 頥 祭,  ஥    
 襭 ணࠬ:  楫. , ᫨  ணࠬ 
 襭 ᯮ 㭪 exit ( _exit),   頥
 祭 㤥 㬥 ⮩ 㭪樨.

      ਬ, ᫨  ணࠬ ᮤন 맮:

      exit(1)

        襭 㤥 ࠢ 1.

      ᫨   ᪠  ணࠬ  ᯮ ⥣஢
 㦥  Borland  C++  (BC.EXE),    ᬮ  頥
 祭 㭪樨 main  , ࠢ "File | Get Info".
      
  2
 
  㭪樨.
      
      ਬ砭:   ਬ  ணࠬ  ⮩  ᮤঠ
  ஥ ࠢ筮 ⥬.   砥,     
  ᪮஢     ⠢  ᢮ 䠩.

         ᮤন  ஡  ᠭ   
 㭪権  Borland   C++.      㭪樨   㯯   
 "ᥬ⢠"  (ਬ,  㭪樨  exec...    spawn...,  
 ᮧ,  㦠  ᪠ ணࠬ),  ..   믮
 宦   ᨬ ⢨.      㭪樨
 ਢ ⤥쭮 ᠭ.   ਬ, ᫨   
 ଠ    㭪樨  free,    㤥 ᪠  free  
 ᠭ 㭪樨   ᫥ ଠ:

      - ᠭ ⮣,   㭪 free,

      - ᨭ⠪  맮 㭪樨 free,

      -   砥  䠩  ᮤন  ⨯  㭪樨
        free,

      - ⠫쭮  ᠭ  ⮣,    ࠡ⠥  free   
        易  㣨 㭪ﬨ,  ।祭묨  
        뤥 ,

      - ᯨ᮪   㣨   ஢,       室
        㭪,

      - 뫪  易 㭪樨 Borland C++,

      - ,  ᫨ 室, ਢ ਬ ᯮ짮 ⮩
        㭪樨     뫪    㭪,    ᠭ  ன
        ਢ 室 ਬ.
        
       ਢ ਬ ,   룫廊 ਬ୮
 ᠭ  筮 㭪樨.
      
                 ᠭ  㭪権.
                 

 㭪樨

㭪            ⪮ ᠭ ⮣,    㭪.

⠪          #include <header.h>
      
                   ( ,  ᮤঠ騥 ⨯  㭪樨
                     ।  ⠭,  塞  ⨯ 
                   .., ᯮ㥬 㭪樥).

                   function(modifier parameter[,...]);

                   ( ᠭ  ᨭ⠪      㭪樨;   [,...]
                   砥,           ⢮   㣨
                   ࠬ   䨪).

, ᮤঠ騩   header.h
⨯
                    ,  ᮤঠ騥 ⨯  㭪樨.
                   ⨯   㭪権 ᮤন  ᪮쪨
                   䠩 ;   ⮬ 砥  
                   䠩.    ᯮ짮  室騩 
                   䠩.

ᠭ            뢠,   㭪, ࠬ,
                       ᯮ,     ஡,
                            ᮢ,      ⠪
                   ᫥ த⢥ 㭪樨.

頥       ਢ  祭, ஥ 㭪
祭           , ᫨  . ᫨ ᯮ
                   쭠 ६ errno,  ਢ ⠪ 
                   祭. (ᠭ 祭  ६  errno  
                     㬥樨  DOS.)

७ᨬ      । ⥬  모,   㯭
                   㭪.    UNIX,  IBM PC  ᮢ⨬
                   , C++, Windows  ⠪ ⠭ ANSI .

 ⠪      㣨 㭪樨,  
                    ᮢ.  ᫨    㭪樨  ᮤন
                   ᫥       (funcname...,       ...funcname,
                   func...name),      ,       
                   ᥬ⢮ 㭪権 (ਬ,  exec...  뫠 
                   楫 ᥬ⢮ 㭪権:  execl,  execle,  execlpe,
                   execv, execve, execvp  execvpe).

ਬ             /*    ਬ 쪮 ணࠬ,
                       ᯮ짮    ⮩    (,
                   , 易  ) 㭪樨. */


abort

㭪            ଠ쭮 襭 믮 ணࠬ.

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

, ᮤঠ騩   stdlib.h,process.h
⨯

ᠭ            㭪 뢮 ᮮ饭  ४饭
                   ࠡ ("Abnormal program termination")  stderr, 
                   뢠  ணࠬ  ।⢮  맮   㭪樨
                   _exit   襭 3.

頥       頥  襭 3  த⥫᪨ 
祭             DOS.

७ᨬ      ন  ⥬ UNIX  ।  ANSI
                   C.

 ⠪     assert, atexit, exit, _exit, raise, signal,
                   spawn...

ਬ:

#include<stdio.h>
#include<stdlib.h>

int main(void)
{
   printf("맮 㭪樨 abort()\n");
   abort();
   return 0; /*  窠  ⨣ */
}


abs

㭪            頥 ᮫⭮ 祭 楫 ᫠.

⠪            ⢥        
                   #include <math.h>            #include<complex.h>
                   int abs(int x);              double abs(complex x);

, ᮤঠ騩     ⢥        
⨯           math.h, stdlib.h             complex.h

ᠭ           㭪 abs 頥 ᮫⭮ 祭 楫
                   㬥 x.   ᫨   㭪  abs  뢠  
                   祭    䠩    stdlib.h,    abs     㤥
                   ਭ          ப,    
                     ஥ .

                   ᫨     ᯮ짮  㭪  abs  
                   ப,   砩   ணࠬ #undef
                   abs ᫥ #include <stdlib.h>.

頥         ⢥ ᥫ 㭪樨 abs 頥
祭           楫 祭    0  32767,  ᪫-
                   祭 ⮣,   㬥 -32768 㤥  饭,
                      -32768.  ᭠    abs  頥
                   祭 ⨯ double.

७ᨬ      ⢥  abs 㯭  ⥬ UNIX 
                   ।  ANSI C. ᭠  abs ॡ
                   ++  ᪮॥ ᥣ ७ᨬ.

 ⠪     cabs, complex, fabs, labs.

ਬ:

#include<stdio.h>
#include<math.h>

int main(void)
{
    int number = -1234;

    printf("᫮ %d ᮫⭮ 祭 %d\n",number,abs(number));
    return 0;
}


absread

㭪            ⥭ ᮫ ᥪ஢  ᪥.

⠪          #include<dos.h>
                   int absread(int drive, int nsects,
                               int lsect, void * buffer);

, ᮤঠ騩   dos.h
⨯

ᠭ           absread 뢠 㪠 ᥪ ᪠. 㭪
                      ᪠   
                     䠩,  FAT  ४ਨ.

                   bsread ⠥    ᥪ ᪠ ।⢮
                   뢠 DOS 0x25.

                   drive  =  ⠥ ᪠ (0=, 1=,  ..)
                   nsects = ⢮ ⠥ ᥪ஢
                   lsect  =  砫 ᪨   ᥪ
                   buffer =  , 㤠 뢠 .

                   ᫮ 뢠      ᥪ஢      ࠭稢
                   ᨬ ࠧ஬  (64)   ,
                   ᫨ ॠ   訩 ࠧ.

頥        ᯥ譮 襭 absread  頥 0.
祭             訡, 㭪 頥
                   祭 -1  ᢠ ६ errno 祭
                   ॣ AX, 砥  ⥬ 맮.

७ᨬ      absread 㭨쭠  DOS.
                   㭪  ন Windows.

 ⠪     abswrite, biosdisk.

ਬ:

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<dos.h>
#include<ctype.h>

#define SEGSIZE 512

unsigned char buf[SEGSIZE];

int main(void)
{
   int i,j,sector,drive;
   char str[10];
   printf("  ᪠:");
   gets(str);
   drive = toupper(str[0])-'A';
   printf("  ᥪ,  㦭 :");
   gets(str);
   sector = atoi(str);
   if(absread(drive,1,sector,&buf)!=0)
   {
      perror("訡 ᪠")
      exit(1);
   }
   printf("\n᪮ %c  %d\n",'A'+drive,sector);
   for(i=0; i<SEGSIZE; i+=16)
   {
      if((i/16)==20)
      {
          printf(" த   ");
          getch();
          printf("\n");
      }
   printf("%03d",i);
   for(j=0;j<16;j++)
      printf("%02X ",buf[i+j]);
   printf("\t");
   for(j=0; j<16;j++)
      if(isprint(buf[i+j]))
          printf("%c",buf[i+j]);
      else
          printf(".");
          printf("\n");
   }
   return 0;
}


abswrite

㭪             ᮫ ᥪ஢  .

⠪          #include<dos.h>
                   int abswrite(int drive, int nsects,
                                int lsect, void * buffer);

, ᮤঠ騩   dos.h
⨯

ᠭ           abswrite 뢠  ᥪ ᪠.
                   㭪    ᪠   
                   頥         䠩,     FAT  
                   ४ਨ.

                   ਬ砭.   ୮  ᯮ짮   abswrite
                    १ 䠩, ४ਨ   FAT.

                   bswrite ந         ᥪ஢    ᪠
                   ।⢮ 뢠 DOS 0x26.

                   drive =  ᪠,   ந 
                           (0=, 1=,  ..)
                   nsects = ⢮ 뢠 ᥪ஢
                   lsect = 砫 ᪨  ᥪ
                   buffer =  , 㤠 뢠 .
                   
                   ᫮ 뢠     ᥪ஢      ࠭稢
                   ᨬ ࠧ஬  (64)   ,
                   ᫨ ॠ   訩 ࠧ.
                   

頥        ᯥ譮 襭 abswrite  頥 0.
祭             訡, 㭪 頥
                   祭 -1  ᢠ ६ errno 祭
                   ॣ AX, 砥  ⥬ 맮. 
                   ⠫    ଠ      rrno   ᬮ   
                   㬥樨  DOS.

७ᨬ      abswrite 㭨쭠  DOS.
                   㭪  ন Windows.

 ⠪     absread, biosdisk.


access

㭪            ।  㯠  䠩.

⠪          #include<io.h>
                   int access(const char * filename, int amode);

, ᮤঠ騩   io.h
⨯

ᠭ           access ஢ 䠩 c  filename 
                   ।,     ,      
                   ⠭, ᠭ  믮.

                   ᮪ 祭 ࠬ amode:
                   
                   06   ஢ઠ ࠧ襭  ⥭  ;
                   04   ஢ઠ ࠧ襭  ⥭;
                   02   ஢ઠ ࠧ襭  ;
                   01   ஢ઠ  믮 ();
                   00   ஢ઠ  ⢮ 䠩;

                   ਬ砭.   ࠢ  樮  ⥬
                   DOS    騥 䠩    ⥭
                   (amode ࠢ 04),  ⮬ 00  04     
                    १.   ⮩  稭 祭 ࠬ
                   amode ,  ᪮  DOS    
                    砥    ⥭.

                   ᫨ ࠬ    filename      뫪   
                   ४,  㭪   access      ஢,
                     ४  .

頥       ᫨ ॡ㥬 ᯮᮡ 㯠 ࠧ襭, access
祭           頥 祭 0,  頥 祭
                   -1   ६  errno  砥   ᫥騩
                   祭:

                     ENOENT -     䠩  
                     EACCES - ⪠ 㯠.

७ᨬ      ন   ⥬ UNIX.

 ⠪     chmod, fstat, stat.

ਬ:

#include <stdio.h>
#include <io.h>

int file_exists(char * filename);

int main(void)
{
   printf("  䠩 NOTEXIST.FIL: %s\n",
      file_exists("NOTEXIST.FIL") ?  "":"");
}

int file_exists(char * filename)
{
   return (access(filename, 0) == 0);
}

:
  䠩 NOTEXIST.FIL: 


acos

㭪             પᨭ.

⠪            ⢥      
                   #include <math.h>          #include<complex.h>
                   double acos(double x);     complex acos(complex x);

, ᮤঠ騩     ⢥        
⨯           math.h                       complex.h

ᠭ           acos 頥 પᨭ  祭.
                   㬥 acos       -1  1.
                   㬥,  室騥  ।  ⮣  ,
                   㦤 acos  NAN  ⠭ errno :

                     EDOM - 訡  ।

                     ᨭ । ᫥騬
                   ࠧ:

                      acos(z)=-i*log(z+i*sqrt(1-z^2))

頥       ⢥  acos 頥 祭  -
祭             0  pi.
                   
                   ࠢ 訡  ⮩ 㭪樨  
                     㭪樨 matherr.

७ᨬ      ⢥  acos ন  ⥬
                   UNIX  ।  ANSI C. ᭠  acos
                   ॡ ++  ᪮॥ ᥣ ७ᨬ.

 ⠪     asin,atan,atan2,complex,cos,matherr,sin,tan

ਬ:

#include<stdio.h>
#include<math.h>

int main(void)
{
   double result;
   double x=0.5;
   result = acos(x);
   printf("પᨭ  %1f ࠢ %1f\n",x,result);
   return 0;
}


allocmem

㭪            뤥 ᥣ  DOS.

⠪          #include<dos.h>
                   int allocmem(unsigned size, unsigned *segp);

, ᮤঠ騩   dos.h
⨯

ᠭ           allocmem  뤥  ᢮ 
                   ᯮ ⥬ 맮 DOS 0x48  頥  
                   ⢥   १    ᥣ  뤥
                   .

                   size -  ࠧ     ࠣ
                   (ࠣ  ࠢ  16  ).  segp  -  㪠⥫ 
                   ᫮,  ஬  㤥  ᢮     ᥣ
                      뤥     .  ᢠ
                    ᫮, 㪠⥫ ண  segp, 
                   ந室,  ᫨  訢 ⢠ 
                      稨.

                    뤥塞  ࠢ  ࠣ䠬.

                   allocmem  malloc   ᯮ짮 .

頥       allocmem  ᯥ譮 襭 -
祭           頥 祭 -1.   訡
                   頥 ᫮ (ࠧ  ࠣ 襣
                    , 饣  稨).

                   訡, 頥     allocmem,  ⠭
                   _doserrno   ६ errno 

                     ENOMEM -  墠⠥ 

७ᨬ      allocmem 㭨쭠  DOS.
                   㭪  ন Windows.

 ⠪     coreleft,freemem,malloc,setblock.

ਬ:

#include<dos.h>
#include<alloc.h>
#include<stdio.h>

int main(void)
{
   unsigned int size,segp;
   int stat;

   size = 64;   /* 64 * 16 = 1024  */
   stat = allocmem(size,&segp);
   if(stat == -1)
      printf("뤥 ᥣ    %x\n",segp);
   else
      printf("訡! ⨬ ᨬ ࠧ = %u\n",stat);
   return 0;
}


arc

㭪              㦭.

⠪          #include <graphics.h>
                   void far arc(int x,int y,int stangle,int endangle,
                                                         int radius);

, ᮤঠ騩   graphics.h
⨯

ᠭ           arc   㦭  業஬  窥
                    न⠬  (x,y)    ࠤᮬ  radius  ⥪騬
                   梥⮬ 뢮.  㣠      㣫 stangle 
                   㣫 endangle.  ᫨ stangle  ࠢ  0    endangle
                   ࠢ 360, 㭪 arc   㦭.

                      arc 뢠 ⨢ ᮢ ५,
                    0 ࠤᮢ ᮮ⢥ 3 ᠬ  ࡫,
                   90 ࠤᮢ - 12 ᠬ  ..

                   砭. ࠬ    linestyle        뢠
                   ⢨     ஥   ,   㦭⥩,
                   ᮢ   ᥪ஢.  ᯮ ⮫쪮 ࠬ
                   thickness.

                   砭. ᫨    ᯮ   CGA      ०
                   ᮪  ࠧ襭    ஬  ᪨
                   ,  ਬ     ᯮ짮   ᪨
                   㭪権,  ਢ   ⮩ ,    
                    १.  ᫨  ⥬  ࠡ⠥
                    CGA  ஬ , । 祭
                   1 ⥬ 㭪,    梥 訢
                    ᮢ,  (ਬ, setcolor, setfillstyle 
                   setlinestyle)  ᨬ᪮ ⠭  梥
                   (।  graphics.h).

頥       .
祭

७ᨬ       㭪 㭨쭠  Borland C++.  ࠡ-
                    ⮫쪮      IBM  PC  ᮢ⨬ 
                   , ᭠饭      ᯫ묨       ࠬ,
                   ন騬   ᪨   ०.  㭪  
                   ᮢ⨬  Windows.

 ⠪     circle, ellipse, fillelipse, getarccoords,
                   getaspectratio, graphresult, pieslice, sector.

ਬ:

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
/*  ⮮। */
int graphdriver = DETECT, gmode, errorcode;
int midx,midy;
int stangle = 45,endangle = 135;
int radius = 100;

/* 樠 䨪   ६ */
initgraph(&graphdriver,&gmode,"");

/* 祭 १ 樠樨 */
errorcode = graphresult();
if(errorcode != grOk)  /* ᫨ 訡 */
{
   printf("訡 :%s\n",grapherrormessage(errorcode));
   printf(" ⠭   \n");
   getch();
   exit(1);  /* 襭   訡 */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor(1));

/*   */
arc(midx,midy,stangle,endangle,radius);

/* ⪠ */
getch();
closegraph();
return 0;
}


arg

㭪            頥 㣮 ᫠  ᭮ ᪮.

⠪          #include<complex.h>
                   double arg(complex x);

, ᮤঠ騩   complex.h
⨯

ᠭ           arg 頥 㣮  ࠤ ᫠  -
                    ᪮.
                   
                   ⥫쭮 ࠢ  ⢥    
                   㣮 0,    ⥫쭮  ࠢ    
                    㣮   Pi/2.   ᫨   㬥,  ।
                   㭪樨,  ࠢ  ᭮  0  (),     arg
                   頥 0.

頥       arg(x) 頥 atan2(imag(x),real(x)).
祭

७ᨬ      㭪樨  ᥫ ॡ ++  ⮬ -
                   ७ᨬ.

 ⠪       complex, norm, polar.

ਬ:

#include<iostream.h>
#include<complex.h>

int main(void)
{
   double x = 3.1, y = 4.2;
   complex z = complex(x,y);
   cout << "z =" << z  << "\n";
   cout << " ⢥  = " << real(z) << "\n";
   cout << "   = " << imag(z) << "\n";
   cout << "z  ᭮ ᮯ殮 = " << conj(z) << "\n";

   double mag = sqrt(norm(z));
   double ang = arg(z);
   cout << "ୠ ଠ z:\n"
   cout << "稭 = " << mag << "\n";
   cout << " ( ࠤ) = " << ang << "\n";
   cout << "⠭  ୮ : \n";
   cout << "   z = " << polar(mag,ang) << "\n";
   return 0;
}


asctime

㭪            ८ࠧ   ६   ASCII.

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

, ᮤঠ騩   time.h
⨯

ᠭ           asctime ८ࠧ ६, ᮤঠ饥  
                     *tblock,  26-ᨬ ப ⠪
                    ,    㭪樨 ctime:

                     Sun Sep 16 01:03:52 1973\n\0

頥       asctime 頥 㪠⥫  ᨬ ப,
祭           ᮤঠ   ६.  ப 
                   ᪮ ६,         ᢮
                   祭   맮 㭪樨 asctime.

७ᨬ      ন  ⥬ UNIX  ।  ANSI
                   C.

 ⠪     ctime, difftime, ftime, gmtime, localtime, mktime,
                   strtime, stime, time, tzset

ਬ:

#include <stdio.h>
#include <string.h>
#include <time.h>

int main(void)
{
     struct tm t;
     char str[80];

/* ⥩襥   */
t.tm_sec     = 1;  /* ᥪ㭤 */
t.tm_min     = 30; /*  */
t.tm_hour    = 9;  /*  */
t.tm_mday    = 22; /*   */
t.tm_mon     = 11; /*  */
t.tm_year    = 56; /*   砥  */
t.tm_wday    = 4;  /*   */
t.tm_yday    = 0;  /*  ⮡ࠦ  asctime */
t.tm_isdst   = 0;  /* ⭥ ६,  ⮡-
                       asctime */
                   
/* ८ࠧ   ப 稢 㫥 */
                   
strcopy(str,asctime(&t));
printf("%s\n",str);
return 0;
}


asin

㭪             ᨭ.

⠪            ⢥      
                   #include <math.h>          #include<complex.h>
                   double asin(double x);     complex asin(complex x);

, ᮤঠ騩     ⢥      
⨯           math.h                     complex.h

ᠭ            asin  ⢥ ᥫ 頥
                   ᨭ   祭.  㬥   㭪樨
                   asin    室    -1  1,  
                   ⨢ 砥 asin 頥 NAN    ⠭
                   errno 

                     EDOM - 訡  ।.

                    ᨭ । ᫥騬 -
                   :

                     asin(z) = -i*log(i*z+sqrt(1-z^2))

頥       ⢥  asin 頥 祭  -
祭             -pi/2  pi/2.
                   
                   ࠢ 訡  ⮩ 㭪樨  
                     㭪樨 matherr.

७ᨬ      ন  ⥬ UNIX  ।  ANSI
                   C. ᭠    asin  ॡ  ++  ᪮॥
                   ᥣ ७ᨬ.

 ⠪     acos, atan, atan2, complex, cos, matherr, sin, tan.

ਬ:

#include <stdio.h>
#include <math.h>

int main(void)
{
   double result;
   double x = 0.5;
   result = asin(x);
   printf("ᨭ  %1f ࠢ %1f\n",x,result);
   return 0;
}


assert

㭪            ஢ ᫮            뢠
                   믮 ணࠬ.

⠪          #include <assert.h>
                   void assert(int test);

, ᮤঠ騩   assert.h
⨯

ᠭ           㭪 assert ।⠢ ᮡ ப,
                       if;  ᫨ ࠬ
                   test  ਭ   㫥   祭,      assert
                   뢠  ணࠬ  (    맮 abort) 
                   뢮 ᮮ饭  stderr.

                   assert 뢮 ᫥饥 ᮮ饭:

             Assertion failed: <test>, file <filename>, line <linenum>

                   樨 filename  linenum, ᫥  ᮮ-
                   ,     室  䠩    ஬
                   ப ணࠬ,  ன  ப
                   assert.

                   ᫨  室   ணࠬ    ⠢  ।
                   ஬  #include  <assert.h>    #define
                   NDEBUG (" ⫠"),    㭪  assert  㤥
                   ਭ  ਩.

頥       .
祭

७ᨬ       ப ন  
                   ⥬ UNIX,   Systems III  V, ᮢ⨬
                    ANSI C.

 ⠪     abort.

ਬ:

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

struct ITEM {
    int   key;
    int   value;
};

/*    ᯨ᮪.
   ஢ઠ,    㫥 */

void additem(struct ITEM *itemptr)
{
   assert(itemptr != NULL);
   /*...   ... */
}

int main(void)
{
   additem(NULL);
   return 0;
}



Assertion failed: itemptr != NULL,
file C:\BC\ASSERT.C, line 12


atan

㭪             ⠭.

⠪            ⢥      
                   #include <math.h>          #include<complex.h>
                   double atan(double x);     complex atan(complex x);

, ᮤঠ騩     ⢥      
⨯           math.h                     complex.h

ᠭ           atan 頥 ⠭  祭.

                    ⠭    ।    ᫥騬
                   ࠧ:

                      atan(z) = -0.5 i log((1+iz)/(1-iz))

頥       ⢥  atan 頥 祭  -
祭             -pi/2  pi/2.
                   
                   ࠢ 訡  ⮩ 㭪樨  
                     㭪樨 matherr.

७ᨬ      ⢥  atan ন  ⥬
                   UNIX  ।    ANSI  C.  ᭠  
                   ॡ ++  ᪮॥ ᥣ ७ᨬ.

 ⠪     acos, asin, atan2, complex, cos, matherr, sin, tan:

ਬ:

#include <stdio.h>
#include <math.h>

int main(void)
{
   double result;
   double x = 0.5;
   result = atan(x);
   printf("⠭  %1f ࠢ %1f\n",x,result);
   return 0;
}


atan2

㭪             ⠭  y/x.

⠪          #include <math.h>
                   double atan2(double y, double x);

, ᮤঠ騩   math.h
⨯

ᠭ           atan2 頥 ⠭  y/x  ந
                   ४஢ १,   ᫨ १騩
                   㣮   pi/2  -pi/2 (x   0).

                   ᫨   x    y  ⠭     0,      㭪
                   ⠭ errno  EDOM.

頥       atan2 頥 祭    -pi  pi.
祭
                   
                   ࠡ 訡  ⮩ 㭪樨    
                    㭪樨 matherr.

७ᨬ      ন  ⥬ UNIX  ।  ANSI
                   C.

 ⠪     acos, asin, atan, cos, matherr, sin, tan.

ਬ:

#include <stdio.h>
#include <math.h>

int main(void)
{
   double result;
   double x = 90.0,y = 15.0;
   result = atan2(x,y);
   printf("⠭  ⭮襭 %1f ࠢ %1f\n",(x/y),result);
   return 0;
}


atexit

㭪             㭪 襭 ࠡ.

⠪          #include<stdlib.h>
                   int atexit(atexit_t func)

, ᮤঠ騩   stdlib.h
⨯

ᠭ           㭪 atexit ॣ 㭪, 㪠⥫
                   ன   ६  func,      㭪
                   室    ணࠬ.    ଠ쭮  襭
                   ணࠬ 㭪 exit 뢠  㭪  (*func)()
                   । ⮬  樮 ⥬.

                    맮  㭪樨  atexit  ॣ  ࠧ
                   㭪樨 室.    ॣ஢   32
                   㭪権.    믮    ᫥饬  浪 -
                   ᫥ ॣ㥬 믮 ࢮ.

頥       㭪 atexit 頥 0  ᯥ譮 -
祭             㫥 祭  㤠筮 襭
                   ( ⠥ , ⮡ ॣ஢ 㭪).

७ᨬ      atexit ᮢ⨬  ANSI C.

 ⠪     abort, _exit, exit, spawn...

ਬ:

#include <stdlib.h>
#include <stdio.h>

void exit_fnl(void)
{
   printf("㭪 室 1\n");
}
void exit_fn2(void)
{
   printf("㭪 室 2\n");
}

int main(void)
{
   /* ᫠ 㭪 室 */
   atexit(exit_fn1);
   /* ᫠ 㭪 室 */
   atexit(exit_fn2);
   printf("襭 main ...\n");
   return 0;
}


atof

㭪            ८ࠧ ப  ᫮  饩 窮.

⠪          #include <math.h>
                   double atof(const char * s);

, ᮤঠ騩   math.h, stdlib.h
⨯

ᠭ           㭪 atof ८ࠧ  ᨬ ப,
                    㪠⥫ ன 室  㬥 s,
                     ᫮    筮 (⨯ double);  
                   㭪 ᯮ ᨬ쭮 ।⠢ ᫠ 
                   饩 窮 ᫥饣 :

                   - 易⥫쭠 ப ⠡樨  ஡;
                   - 易⥫ ;
                   - ப   易⥫  
                     (  室   ஭  窨);
                   - 易⥫  ᨬ  e    E,    묨
                     ᫥ 易⥫쭮 楫  .

                     ᮮ⢥⢮ ᫥饬 ଠ:

                     [஡] [] [ddd] [.] [ddd] [e|E[]ddd]

                   atof ⠪ ᯮ +INF  -INF     
                   ᪮筮, +NAN  -NAN  ᫮ 祭.

                    㭪  ४頥  ८ࠧ    ࢮ
                   ᯮ ᨬ.

                   strtod 筠    atof;            襥
                   ᯮ 訡,  ⮬   
                   ।⥫쭥.

頥       atof 頥 ८ࠧ 祭 㪠
祭           ᨬ쭮 ப.

                    砥 ९ atof 頥 ⥫쭮
                     ⥫쭮  祭  HUGE_VAL,  쭠
                   ६ errno ⠭  ERANGE  㭪
                   matherr  뢠.

७ᨬ      ন  ⥬ UNIX  ।  ANSI
                   C.

 ⠪     atoi, atol, ecvt, fcvt, gcvt, scanf, strtod.

ਬ:

#include<stdlib.h>
#include<stdio.h>

int main(void)
{
   float f;
   char *str = "12345.678";
   f = atof(str);
   printf("ப = %s 祭 = %5.3f\n",str,f);
   return 0;
}


atoi

㭪            ८ࠧ ப  楫 ᫮.

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

, ᮤঠ騩   stdlib.h
⨯

ᠭ           㭪 atoi ८ࠧ  ᨬ ப,
                    㪠⥫ ன 室  㬥 s,
                    ᫮  ⨯  int;    㭪  ᯮ  
                   ᫥饬 浪:

                   - 易⥫ ப ⠡樨  ஡;
                   - 易⥫ ;
                   - ப .

                     ᮮ⢥⢮ ᫥饬 ଠ:

                     [஡] [] [ddd]

                    㭪  ४頥  ८ࠧ    ࢮ
                   ᯮ ᨬ.

                   atoi  ᫥ ९.

頥       atoi 頥 ८ࠧ 祭
祭           室 ᨬ쭮 ப. ᫨ ப  
                    ८ࠧ   ᫮  ᮮ⢥饣  ⨯
                   (int),  頥 祭 ࠢ 0.

७ᨬ      ন  ⥬ UNIX  ।  ANSI
                   C.

 ⠪     atof, atol, ecvt, fcvt, gcvt, scanf, strtod.

ਬ:

#include<stdlib.h>
#include<stdio.h>

int main(void)
{
   int n;
   char *str = "12345";
   n = atoi(str);
   printf("ப = %s 楫 = %d\n",str,n);
   return 0;
}


atol

㭪            ८ࠧ ப  ᫮ ⨯ long.

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

, ᮤঠ騩   stdlib.h
⨯

ᠭ           㭪 atol ८ࠧ  ᨬ ப,
                    㪠⥫ ன 室  㬥 s,
                     ᫮  ⨯  long.    㭪 ᯮ 
                   ᫥饬 浪:

                   - 易⥫ ப ⠡樨  ஡;
                   - 易⥫ ;
                   - ப .

                     ᮮ⢥⢮ ᫥饬 ଠ:

                     [஡] [] [ddd]

                    㭪  ४頥  ८ࠧ    ࢮ
                   ᯮ ᨬ.

                   atol    ᫥  ९  (१  
                   ।).

頥       atol 頥 ८ࠧ 祭
祭           室 ᨬ쭮 ப. ᫨ ப  
                    ८ࠧ   ᫮  ᮮ⢥饣  ⨯
                   (long),  頥 祭 ࠢ 0.

७ᨬ      ন  ⥬ UNIX  । ANSI
                   C.

 ⠪     atof, atoi, ecvt, fcvt, gcvt, scanf, strtod, strtol,
                   strtoul.

ਬ:

#include<stdlib.h>
#include<stdio.h>

int main(void)
{
   int n;
   char *str = "12345";
   n = atoi(str);
   printf("ப = %s 楫 = %d\n",str,n);
   return 0;
}

