站長(zhǎng)資訊網(wǎng)
        最全最豐富的資訊網(wǎng)站

        C語(yǔ)言函數(shù)大全 d

        函數(shù)名: delay          
        功  能: 將程序的執(zhí)行暫停一段時(shí)間(毫秒)
        用  法: void delay(unsigned milliseconds);
        程序例:
        /* Emits a 440-Hz tone for 500 milliseconds */
        #include <dos.h>

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

           return 0;
        }
         
         

        函數(shù)名: delline
        功  能: 在文本窗口中刪去一行
        用  法: void delline(void);
        程序例:

        #include <conio.h>

        int main(void)
        {
           clrscr();
           cprintf(“The function DELLINE deletes
            the line containing thern”);
           cprintf(“cursor and moves all lines
            below it one line up.rn”);
           cprintf(“DELLINE operates within the
            currently active textrn”);
           cprintf(“window.  Press any key to
            continue . . .”);
           gotoxy(1,2);  /* Move the cursor to the
              second line and first column */
           getch();

           delline();
           getch();

           return 0;
        }
         

        函數(shù)名: detectgraph
        功  能: 通過(guò)檢測(cè)硬件確定圖形驅(qū)動(dòng)程序和模式
        用  法: void far detectgraph(int far *graphdriver, int far *graphmode);
        程序例:

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

        /* names of the various cards supported */
        char *dname[] = { “requests detection”,
            “a CGA”,
            “an MCGA”,
            “an EGA”,
            “a 64K EGA”,
            “a monochrome EGA”,
            “an IBM 8514”,
            “a Hercules monochrome”,
            “an AT&T 6300 PC”,
            “a VGA”,
            “an IBM 3270 PC”
          };

        int main(void)
        {
           /* returns detected hardware info. */
           int gdriver, gmode, errorcode;

          /* detect graphics hardware available */
           detectgraph(&gdriver, &gmode);

           /* read result of detectgraph call */
           errorcode = graphresult();
           if (errorcode != grOk)  /* an error
                 occurred */
           {
              printf(“Graphics error: %sn”,
              grapherrormsg(errorcode));
              printf(“Press any key to halt:”);
              getch();
              exit(1); /* terminate with an error
            code */
           }

           /* display the information detected */
           clrscr();
           printf(“You have %s video display
           card.n”, dname[gdriver]);
           printf(“Press any key to halt:”);
           getch();
           return 0;
        }
         
         
         

        函數(shù)名: difftime
        功  能: 計(jì)算兩個(gè)時(shí)刻之間的時(shí)間差
        用  法: double difftime(time_t time2, time_t time1);
        程序例:

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

        int main(void)
        {
           time_t first, second;

           clrscr();
           first = time(NULL);  /* Gets system
              time */
           delay(2000);         /* Waits 2 secs */
           second = time(NULL); /* Gets system time
              again */

           printf(“The difference is: %f
           secondsn”,difftime(second,first));
           getch();

           return 0;
        }
         
         

        函數(shù)名: disable
        功  能: 屏蔽中斷
        用  法: void disable(void);
        程序例:

        /***NOTE: This is an interrupt service
         routine. You cannot compile this program
         with Test Stack Overflow turned on and
         get an executable file that operates
         correctly. */

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

        #define INTR 0X1C    /* The clock tick
           interrupt */

        void interrupt ( *oldhandler)(void);

        int count=0;

        void interrupt handler(void)
        {
        /* disable interrupts during the handling of
           the interrupt */
           disable();
        /* increase the global counter */
           count++;
        /* reenable interrupts at the end of the
           handler */
           enable();
        /* call the old routine */
           oldhandler();
        }

        int main(void)
        {
        /* save the old interrupt vector */
           oldhandler = getvect(INTR);

        /* install the new interrupt handler */
           setvect(INTR, handler);

        /* loop until the counter exceeds 20 */
           while (count < 20)
              printf(“count is %dn”,count);

        /* reset the old interrupt handler */
           setvect(INTR, oldhandler);

           return 0;
        }

        函數(shù)名: div
        功  能: 將兩個(gè)整數(shù)相除, 返回商和余數(shù)
        用  法: div_t (int number, int denom);
        程序例:

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

        div_t x;

        int main(void)
        {
           x = div(10,3);
           printf(“10 div 3 = %d remainder %dn”, x.quot, x.rem);

           return 0;
        }
         
         

        函數(shù)名: dosexterr
        功  能: 獲取擴(kuò)展DOS錯(cuò)誤信息
        用  法: int dosexterr(struct DOSERR *dblkp);
        程序例:

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

        int main(void)
        {
           FILE *fp;
           struct DOSERROR info;

           fp = fopen(“perror.dat”,”r”);
           if (!fp) perror(“Unable to open file for
             reading”);
           dosexterr(&info);

           printf(“Extended DOS error
           information:n”);
           printf(”   Extended error:
           %dn”,info.exterror);
           printf(”            Class:
           %xn”,info.class);
           printf(”           Action:
           %xn”,info.action);
           printf(”      Error Locus:
           %xn”,info.locus);

           return 0;
        }
         
         

        函數(shù)名: dostounix
        功  能: 轉(zhuǎn)換日期和時(shí)間為UNIX時(shí)間格式
        用  法: long dostounix(struct date *dateptr, struct time *timeptr);
        程序例:

         #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(“Time and Date: %sn”,
            asctime(local));

            return 0;
        }
         
         

        函數(shù)名: drawpoly
        功  能: 畫(huà)多邊形
        用  法: void far drawpoly(int numpoints, int far *polypoints);
        程序例:

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

        int main(void)
        {
           /* request auto detection */
           int gdriver = DETECT, gmode, errorcode;
           int maxx, maxy;

           /* our polygon array */
           int poly[10];

           /* initialize graphics and local
              variables */
           initgraph(&gdriver, &gmode, “”);

           /* read result of initialization */
           errorcode = graphresult();
           if (errorcode != grOk)
           /* an error occurred */
           {
              printf(“Graphics error: %sn”,
              grapherrormsg(errorcode));
              printf(“Press any key to halt:”);
              getch();
           /* terminate with an error code */
              exit(1);
           }

           maxx = getmaxx();
           maxy = getmaxy();

           poly[0] = 20;        /* 1st vertext */
           poly[1] = maxy / 2;

           poly[2] = maxx – 20; /* 2nd */
           poly[3] = 20;

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

           poly[6] = maxx / 2;  /* 4th */
           poly[7] = maxy / 2;
        /*
           drawpoly doesn’t automatically close
           the polygon, so we close it.
        */
           poly[8] = poly[0];
           poly[9] = poly[1];

           /* draw the polygon */
           drawpoly(5, poly);

           /* clean up */
           getch();
           closegraph();
           return 0;
        }
         
         

        函數(shù)名: dup
        功  能: 復(fù)制一個(gè)文件句柄
        用  法: int dup(int handle);
        程序例:

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

        void flush(FILE *stream);

        int main(void)
        {
           FILE *fp;
           char msg[] = “This is a test”;

           /* create a file */
           fp = fopen(“DUMMY.FIL”, “w”);

           /* write some data to the file */
           fwrite(msg, strlen(msg), 1, fp);

           clrscr();
           printf(“Press any key to flush
           DUMMY.FIL:”);
           getch();

           /* flush the data to DUMMY.FIL without
              closing it */
           flush(fp);

           printf(“nFile was flushed, Press any
           key to quit:”);
           getch();
           return 0;
        }

        void flush(FILE *stream)
        {
           int duphandle;

           /* flush TC’s internal buffer */
           fflush(stream);

           /* make a duplicate file handle */
           duphandle = dup(fileno(stream));

           /* close the duplicate handle to flush the
              DOS buffer */
           close(duphandle);
        }
         
         

        函數(shù)名: dup2
        功  能: 復(fù)制文件句柄
        用  法: int dup2(int oldhandle, int newhandle);
        程序例:

        #include <sysstat.h>
        #include <string.h>
        #include <fcntl.h>
        #include <io.h>

        int main(void)
        {
           #define STDOUT 1

           int nul, oldstdout;
           char msg[] = “This is a test”;

           /* create a file */
           nul = open(“DUMMY.FIL”, O_CREAT | O_RDWR,
              S_IREAD | S_IWRITE);

           /* create a duplicate handle for standard
              output */
           oldstdout = dup(STDOUT);
           /*
              redirect standard output to DUMMY.FIL
              by duplicating the file handle onto the
              file handle for standard output.
           */
           dup2(nul, STDOUT);

           /* close the handle for DUMMY.FIL */
           close(nul);

           /* will be redirected into DUMMY.FIL */
           write(STDOUT, msg, strlen(msg));

           /* restore original standard output
              handle */
           dup2(oldstdout, STDOUT);

           /* close duplicate handle for STDOUT */
           close(oldstdout);

           return 0;
        }

         

        贊(0)
        分享到: 更多 (0)
        網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)
        主站蜘蛛池模板: 97精品国产自在现线免费观看| 精品无码久久久久久久动漫| 国产精品尹人在线观看| 精品久久久噜噜噜久久久| 精品无人区无码乱码大片国产| 久久精品一区二区三区不卡| 久久精品www人人爽人人| 日韩精品一区二区三区在线观看| 四虎国产精品永久地址99新强| jizz国产精品网站| 久久精品国产亚洲AV无码偷窥 | 最新国产精品无码| 国产系列高清精品第一页| 一区二区三区精品| 香蕉国产精品频视| 天天爽夜夜爽精品视频app| 国产欧美久久久精品| 大桥未久在线精品视频在线| 国产精品区免费视频| 久久夜色精品国产欧美乱| 亚洲AV永久无码精品一百度影院 | 亚洲自偷自偷精品| 亚洲国产精品lv| 99久久国产主播综合精品 | 精品久久一区二区三区| 国产在线精品一区二区不卡| 2020久久精品国产免费| 国产a精品视频| 久久成人国产精品二三区| 日本精品久久久中文字幕| 久久伊人精品青青草原高清| 亚洲精品视频在线| 国产福利精品在线观看| 国产2021久久精品| 精品欧美激情在线看| 久久夜色精品国产亚洲av| 亚洲а∨天堂久久精品| 中文字幕精品无码一区二区三区| 中国精品18videosex性中国| 日韩人妻精品无码一区二区三区 | 国产精品一区二区三区99|