
delay

㭪            ࠦ 믮 ணࠬ  ࢠ 
                   ᥪ㭤.

⠪          #include<dos.h>
                   void delay (unsigned milliseconds);

, ᮤঠ騩   dos.h
⨯

ᠭ            맮   㭪樨   delay  믮  ணࠬ
                   ਮ⠭        ६,     ।塞
                   ࠬ஬      milliseconds.          ⯠
                   室  ஢筮 맮  delay.  delay
                   뢠 ࢠ  ᥪ㭤.

頥       .
祭

७ᨬ       㭪    ࠡ⠥   ⮫쪮      
                   ᮢ⨬   IBM  PC.  㭪    ᮢ⨬  
                   Windows.

 ⠪     nosound, sleep, sound.

ਬ:

/*   뤠   ⮩ 440   祭
     500 ᥪ㭤  */

#include <dos.h>

int main(void)
{
   sound(440);
   delay(500);
   nosound();
   return 0;
}


delline

㭪             ப  ⥪⮢ .

⠪          #include<conio.h>
                   void delline(void);

, ᮤঠ騩   conio.h
⨯

ᠭ           delline 㤠 ப,  ன 室 
                    ᤢ  ப        .
                   delline ࠡ⠥  ⥪饣 ⨢ .

頥       .
祭

७ᨬ       㭪    ࠡ⠥   ⮫쪮      
                   ᮢ⨬   IBM  PC.  㭪    ᮢ⨬  
                   Windows.

 ⠪     clreol, clrscr, insline, window.

ਬ:

#include<conio.h>

int main(void)
{
   clrscr();
   cprintf("㭪 DELLINE 㤠 ப, ᮤঠ \r\n");
   cprintf(" ६頥  ப, 騥  ,  \r\n");
   cprintf("ப . DELLINE ࠡ⠥  ⥪饬 ⨢ \r\n");
   cprintf("⥪⮢ .  த  ...");
   gotoxy(1,2); /* ६    ப */
   getch();
   delline();
   getch();
   return 0;
}


detectgraph

㭪            । ᪨ ࠩ  ᪨ ०
                    ஢થ .

⠪          #include <graphics.h>
                   void far detectgraph (int far*graphdriver,
                      int far *graphmode);

, ᮤঠ騩   graphics.h
⨯

ᠭ           detectgraph ।    ⥬  ᪨
                       롨ࠥ  ०,    ᯥ稢
                   ᠬ ᮪ ࠧ襭  ⮣  .  ᫨
                   ᪨       㦥,  *graphdriver
                   ⠭   -2    graphresult  㤥  ⠪
                    -2 (grNotDetected).

                   *graphdriver -    楫,     ஥     ।
                   ᯮ㥬 ᪨ ࠩ.    
                    祭,  ᯮ  ⠭  塞
                   ⨯ graphics_drivers,  ।  graphics.h 
                   ਢ  ᫥饩 ⠡.
                   
                    2.1. ⠭ 㭪樨 detectgrapf.
                   __________________________________________
                    graphics_drivers
                    ⠭           ᫥ 祭
                   __________________________________________
                    DETECT              0 (訢
                                           ⮮।
                                           ࠩ)
                    CGA                 1
                    MCGA                2
                    EGA                 3
                    EGA64               4
                    EGAMONO             5
                    IBM8514             6
                    HERCMONO            7
                    ATT400              8
                    VGA                 9
                    PC3270              10
                   __________________________________________

                   *graphmode - 楫,  ஥  ।  砫
                   ᪨   ०  (᫨  *graphdriver    ࠢ
                   DETECT,  *graphmode  ⠭     襥
                   ࠧ襭, ⨬     ࠩ).  
                        祭   *graphmode,   ᯮ
                   ⠭   塞   ⨯   graphics_modes,
                   ।  graphics.h     ᫥饩
                   ⠡:
      
       2.2. ଠ ᪨ ࠩ஢.
      
      .  graphics   .         ࠭
      ࠩ     _modes            * ⮫殢
      
      CGA         CGAC0       0     320 x 200   C0          1
                  CGAC1       1     320 x 200   C1          1
                  CGAC2       2     320 x 200   C2          1
                  CGAC3       3     320 x 200   C3          1
                  CGAHI       4     640 x 200   2梥      1

      MCGA        MCGAC0      0     320 x 200   C0          1
                  MCGAC1      1     320 x 200   C1          1
                  MCGAC2      2     320 x 200   C2          1
                  MCGAC3      3     320 x 200   C3          1
                  MCGAMED     4     640 x 200   2梥      1
                  MCGAHI      5     640 x 480   2梥      1

      EGA         EGALO       0     640 x 200   16梥⮢    4
                  EGAHI       1     640 x 350   16梥⮢    2

      EGA64       EGA64LO     0     640 x 200   16梥⮢    1
                  EGA64HI     1     640 x 350   4 梥     1

      EGA-        EGAMONOHI   3     640 x 350   2 梥     1*
      MONO        EGAMONOHI   3     640 x 350   2 梥     2**

      HERC        HERCMONOHI  0     720 x 348   2 梥     2

      AT400       ATT400C0    0     320 x 200   C0          1
                  ATT400C1    1     320 x 200   C1          1
                  ATT400C2    2     320 x 200   C2          1
                  ATT400C3    3     320 x 200   C3          1
                  ATT400MED   4     640 x 200   2 梥     1
                  ATT400HI    5     640 x 400   2 梥     1

      VGA         VGALO       0     640 x 200   16 梥⮢   2
                  VGAMED      1     640 x 350   16 梥⮢   2
                  VGAHI       2     640 x 380   16 梥⮢   1

      PC3270      PC3270HI    0     720 x 350   2 梥     1

      IBM8514     IBM8514HI   0     640 x 480   256 梥⮢
                  IBM8514LO   0    1024 x 768   256 梥⮢

       *  64   EGAMONO
      **  256   EGAMONO
      

                    砭. ᭮ 稭 맮 ।⢥
                    detectgraph ⮨  ८। ᪮
                    ०,       detectgraph      ४
                    initgraph.

頥        .
祭

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

 ⠪     graphresult, initgraph.

ਬ:

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

/*  ࠧ ᪨ ஢ */
char *gname[] = { "ॡ ।",
                  "MCGA",
                  "CGA",
                  "EGA",
                  "EGA  64K",
                  "஬ EGA",
                  "IBM 8514",
                  "Hercules ஬",
                  "AT&T 6300 PC",
                  "VGA",
                  "IBM 3270" };

int main(void)
{
/* ᯮ  । ᪮  */
int graphdriver, gmode, errorcode;
/* ।  */
detectgraph(&graphdriver,&gmode,"");
/* 祭 १ 樠樨 */
errorcode = graphresult();
if(errorcode != grOk)  /* ᫨ 訡 */
{
   printf("訡 :%s\n",grapherrormessage(errorcode));
   printf(" ⠭   \n");
   getch();
   exit(1);  /* 襭   訡 */
}
/* 뢥 祭 ଠ */
clrscr();
printf("⠭ : %s",gname[graphdriver]);
printf(" 襭   ...");
getch();
return 0;
}


diftime

㭪             ࠧ     ६.

⠪          #include <time.h>
                   double difftime(time_t time2, time_t time1);

, ᮤঠ騩   time.h
⨯

ᠭ           difftime  ६  ᥪ㭤  time1 
                   time2.

頥       頥 १ ᫥ ⨯ double.
祭

७ᨬ      ⨬  UNIX  ।  ANSI C.

 ⠪     asctime, ctime, daylight (६), gmtime,
                   localtime, time, timezone (६).

ਬ:

#include<time.h>
#include<stdio.h>
#include<dos.h>
#include<conio.h>

int main(void)
{
   time_t first,second;
   clrscr();
   first = time(NULL); /*  ⥬ ६ */
   delay(2000);        /* প  2000 ᥪ㭤 */
   second = time(NULL);/*   ⥬ ६ */
   printf(" ࠢ %f ᥪ㭤",difftime(second,first);
   getch();
   return 0;
}


disable

㭪            頥 뢠.

⠪          #include <dos.h>
                   void disable(void);

, ᮤঠ騩   dos.h
⨯

ᠭ            ப ࠧࠡ⠭  楫 ᯥ祭
                   ணࠬ⮢      ।⢮   ஫   
                   뢠ﬨ  䨧᪮ ஢.

                   ப disable               뢠
                   묨.  襭 ⮫쪮  뢠  NMI  
                   譥 ன⢠ (᪨㥬 뢠).

頥       .
祭

७ᨬ       ப 㭨쭠  ⥪ 8086.

 ⠪     getvect, enable.

ਬ:

/* 砭.
    ணࠬ  ࠡ⪨ 뢠.    c ⪮஢
    ணࠬ  祭 ஢મ ९ ⥪ (Test Stack
   Overflow - On)   ࠢ쭮 ࠡ ணࠬ. */

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

#define INTR 0X1C  /* 뢠 ⠩ */

void interrupt (*oldhandler)(void);

int count=0;

void interrupt handler(void)
{
   /*  㣨 뢠  ६ ࠡ⪨ ⮣ */
   disable();
   /* 㢥祭 쭮 稪 */
   count++;
   /* ࠧ襭 뢠 ᫥ ࠡ⪨ */
   enable();
   /* 맮 ன ணࠬ ࠡ⪨ */
   oldhandler();
}
int main(void)
{
   /* ࠭   */
   oldhandler = getvect(INTR);
   /*    */
   setvect(INTR,handler);
   /* 横,  稪  ⨣ 20 */
   while(count < 20)
      printf("稪 = %d\n",count);
   /* ⠭   */
   setvect(INTR,oldhandler);
   return 0;
}


div

㭪            ந   楫  頥 ⭮
                    ⮪.

⠪          #include <stdlib.h>
                   div_t div(int numer, int denom);

 ᮤঠ騩    stdlib.h
⨯

ᠭ           div    楫  頥 ⭮  ⮪
                     ⨯ div_t.  numer - ,  denum  -
                   ⥫.    div_t  ।   stdlib.h
                   ᫥騬 ࠧ:

                   typedef struct {
                      int quot;       /*  ⭮  */
                      int rem;        /*  ⮪  */
                   } div_t;

頥       div 頥  ⨯ div_t, ᮤঠ
祭           ⭮  ⮪  .

७ᨬ      div ᮢ⨬   ANSI C.

 ⠪     ldiv.

ਬ:

#include<stdlib.h>
#include<stdio.h>
                   
div_t x;

int main(void)
{
    x = div(10,3);
    printf("10 div 3 = %d,  = %d",x.quot,x.rem);
    return 0;
}
뢮:
10 div 3 = 3  = 1


dosexterr

㭪            砥 ⥫  訡 DOS.

C⠪          #include <dos.h>
                   int dosexterr(struct DOSERROR *eblkp);

, ᮤঠ騩   dos.h
⨯

ᠭ            㭪        DOSERROR  
                    㪠⥫ eblkp  ७  ଠ樥
                     訡,  砥    㤠筮  襭
                   ⥬   맮   DOS.        DOSERROR
                   । ᫥騬 ࠧ:

                   struct  DOSERROR {
                      int exterror;     /* ⥫쭠 訡 */
                      char class;       /*  訡 */
                      char action;      /* ⢨ */
                      char locus;       /* ⮭宦 訡 */
                   };

                   祭   砥   맮
                   㭪樨 DOS 0x59.  祭 exterror,  ࠢ ,
                   砥,  ।騩 맮 ⥬ MS DOS
                   訫  訡.

頥       㭪 dosexterr 頥 祭 ६
祭           exterror.

७ᨬ      㭪 㭨쭠  ⥬ MS DOS ᨨ 3.X,
                   ⮬    ᯮ짮     ࠭
                    ⥬ DOS.

ਬ:

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

int main(void)
{
   FILE *fp;
   struct DOSERROR info;
   fp = fopen("perror.dat","r");
   if(!fp) perror("   䠩  ⥭");
   dosexterror(&info);
   printf("⥫쭠 ଠ  訡 DOS:\n");
   printf("  ⥫쭠 訡:    %d\n",info.exterror);
   printf("            訡:    %d\n",info.class);
   printf("               ⢨:    %d\n",info.action);
   printf(" ⮭宦 訡:    %d\n",info.locus);
   return 0;
}


dostounix

㭪            ८ࠧ   ६  ଠ ⥬ UNIX.

⠪          #include <dos.h>
                   long dostounix(struct date *d,struct dostime *t);

, ᮤঠ騩   dos.h
⨯

ᠭ           㭪 dostounix   ८ࠧ         ६,
                   砥 㭪ﬨ getdate    gettime    ଠ
                   ⥬   UNIX.   㬥   d     
                   㪠⥫  date,   㬥 t  㪠뢠
                         dostime,   ᮤঠ騥   ४
                   ଠ  ६   ⥬ DOS.

頥       㭪 dostounix 頥 ⥪饥 ६
祭           ⥬ UNIX: ⢮ ᥪ㭤, 稭  1 ﭢ-
                    1970, 00:00:00 (६  ਭ).

७ᨬ      㭪 㭨쭠  ⥬ DOS.

 ⠪     unixtodos.

ਬ:

#include<time.h>
#include<stddef.h>
#include<dos.h>
#include<stdio.h>

int main(void)
{
   time_t t;
   struct time d_time;
   struct date d_date;
   struct tm *local;

   getdate(&d_date);
   gettime(&d_time);
   t = dostounix(&d_date,&d_time);
   local = localtime(&t);
   printf("६  : %s\n",asctime(local));
   return 0;
}


drawpoly

㭪              㣮쭨.

⠪          #include <graphics.h>
                   void far drawpoly (int numpoints,
                                       int far *polypoints);

, ᮤঠ騩   graphics.h
⨯

ᠭ
                   drawpoly   㣮쭨,  騩  numpoints
                   祪, ᯮ ⥪騥 ⨯   梥.

                   *polypoints 㪠뢠      ᫥⥫쭮  
                   (numpoints x 2) 楫 ᥫ.    ᥫ x 
                   y  न⠬ 設 㣮쭨.

                   砭.  ஥ ⮩ 䨣, 饩
                   n 設,  室  n+1 न,  
                   n- न⭠  ࠢ 0-.

頥       .
祭

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

 ⠪     fillpoly, floodfill, graphresult, setwritemode.

ਬ:

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

int main(void)
{
/*  ⮮। */
int graphdriver = DETECT, gmode, errorcode;
int maxx,maxy;
/*  㣮쭨 */
int poly[10];

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

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

poly[0] = 20;        /* ࢠ 窠 */
poly[1] = maxy/2;

poly[2] = maxx-20;   /* 2 */
poly[3] = 20;

poly[4] = maxx-50;   /* 3 */
poly[5] = maxy-20;

poly[6] = maxx/2;    /* 4 */
poly[7] = maxy/2;

poly[8] = poly[0];   /*   室 . */
poly[9] = poly[1];

/*  㣮쭨 */
drawpoly(5,poly);

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


dup

㭪            㡫 ਯ 䠩.

⠪          #include<io.h>
                   int dup(int handle);

, ᮤঠ騩   io.h
⨯

ᠭ           㭪 dup 頥 ਯ 䠩, 
                    ᫥騬    ᮢ     ਣ
                   ਯ஬:

                   -   ᠬ 뢠 䠩  ன⢮.

                   -     ᠬ   㪠⥫ 䠩 ( 
                       ᭮ 㪠⥫  ਢ  
                      㣮).

                   -     ᠬ  ⮤  㯠  (⥭,  ,
                     ⥭/).

                   ६ handle  砥  祭     맮
                   㭪権 creat,_creat,_open, open, dup, dup2.

頥        ᯥ譮 襭 㭪 dup 頥 -
祭            ⥫쭮 ᫮, 饥 ᮮ⢥-
                   騩 ਯ 䠩;  ⨢ 砥 㭪
                   dup 頥 祭 -1.

                      訡   쭠   ६
                   errno 砥   ᫥ 祭:

                     EMFILE - 誮   䠩.
                     EBADF  -   䠩.

७ᨬ      㭪 dup ন  ⥬ UNIX.

 ⠪     _close, close, _creat, creat, creatnew, creattemp,
                   dup2, fopen, _open, open.

ਬ:

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

void flash(FILE *stream);

int main(void)
{
   FILE *fp;
   char msg[] = "⮢ ਬ";
   /* ᮧ 䠩 */
   fp = fopen("DUMMY.FIL,"w");
   if(fp)
   {
      /*   䠩  */
      fwrite(msg,strlen(msg),1,fp);
      clrscr();
      printf("   ஢ 䠩     ");
      getch();
      /*  ஢ 䠩      */
      flush(fp);
      printf(" ᠭ,  襭  .");
      getch();
   }
   else
   {
      printf("訡  ⨨ 䠩\n");
   }
   return 0;
}
void flash(FILE *stream)
{
   int duphandle;
   /*  ७  TC */
   fflash(stream);
   /* 㡫஢ ਯ 䠩 */
   duphandle = dup(fileno(stream));
   /*  ன ਯ,   ७ ஢ DOS */
   close(duphandle);
}


dup2

㭪            㡫 ਯ 䠩.

⠪          #include<io.h>
                   int dup2(int oldhandle, int newhandle);

, ᮤঠ騩   io.h
⨯

ᠭ           㭪 dup2  ਯ 䠩, 
                    ᫥騬     ᮢ    ਣ
                   ਯ஬:

                   -   ᠬ 뢠 䠩  ன⢮.

                   -   ᠬ  㪠⥫  䠩  (  
                        ᭮  㪠⥫ ਢ 
                      㣮).

                   -     ᠬ  ⮤  㯠  (⥭,  ,
                     ⥭/).

                   dup2 ᮧ       ਯ      祭
                   newhandle  ᫨  䠩  易      ਯ஬
                   newhandle   ,         맮   dup2   
                   뢠.

                   ६ newhandle  oldhandle -   ਯ
                   䠩,      祭    맮 㭪権
                   creat,_creat,_open, open, dup, dup2.

頥        ᯥ譮 襭 㭪 dup2 頥 0,
祭            ⨢ 砥 㭪 dup2 頥 祭
                   -1.

                      訡   쭠   ६
                   errno 砥   ᫥ 祭:

                     EMFILE - 誮   䠩.
                     EBADF  -   䠩.

७ᨬ      㭪 dup ন  ⥬ UNIX, ஬
                   System III.

 ⠪     _close, close, _creat, creat, creatnew, creattemp,
                   dup2, fopen, _open, open.

ਬ:

#include<sys\stat.h>
#include<string.h>
#include<fcntl.h>
#include<io.h>
#include<stdio.h>
#define STDOUT 1

int main(void)
{
   int fptr,oldstdout;
   char msg[] = "⮢ ਬ";
   /* ᮧ 䠩 */
   fptr = open("DUMMY.FIL",O_CREAT|O_RDWR,S_IREAD|S_IWRITE);
   if(fptr)
   {
      /* ᮧ ⥫ ਯ  stdout */
      oldstdout = dup(STDOUT);
      /* ७ࠢ ⠭ 뢮  䠩, ⥬
         㡫஢  ਯ */
      dup2(fptr,STDOUT);
      /*  䠩 */
      close(fptr);
      /* 뫮 ७ࠢ  DUMMY.FIL */
      write(STDOUT,msg,strlen(msg));
      /* ⠭ 室 ਯ stdout */
      dup2(oldstdout,STDOUT);
      /*  ன ਯ stdout */
      close(oldstdout);
   }
   else
   {
      printf("訡  ⨨ 䠩. \n");
   }
   return 0;
}

