当前位置: 首页 > news >正文

网站建设彩票网站优化课程

网站建设彩票,网站优化课程,浙江专业做网站,郑州建设信息网信用评价系统C语言函数大全 本篇介绍C语言函数大全–d开头的函数 1. detectgraph 1.1 函数说明 函数声明函数功能void detectgraph(int *graphdriver, int *graphmode);通过检测硬件确定图形驱动程序和模式 1.2 演示示例 #include <graphics.h> #include <stdlib.h> #incl…

C语言函数大全

本篇介绍C语言函数大全–d开头的函数

1. detectgraph

1.1 函数说明

函数声明函数功能
void detectgraph(int *graphdriver, int *graphmode);通过检测硬件确定图形驱动程序和模式

1.2 演示示例

#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);/* initialize graphics and local variables */initgraph(&gdriver, &gmode, "");/* read result of detectgraph call */errorcode = graphresult();if (errorcode != grOk)  /* an error occurred */{printf("Graphics error: %s\n", grapherrormsg(errorcode));printf("Press any key to halt:");getch();exit(1); /* terminate with an error code */}/* display the information detected */printf("You have [%s] video display card.\n", dname[gdriver]);printf("Press any key to halt:");getch();return 0;
}

1.3 运行结果

在这里插入图片描述

2. difftime

2.1 函数说明

函数声明函数功能
double difftime(time_t time2, time_t time1);计算两个时刻之间的时间差

2.2 演示示例

#include <stdio.h>
#include <time.h>int main(void)
{time_t first, second; // time_t 相当于 longfirst = time(NULL);  // Gets system time getchar();second = time(NULL); // Gets system time again printf("The difference is: %lf seconds\n", difftime(second, first));return 0;
}

2.3 运行结果

在这里插入图片描述

3. div

3.1 函数说明

函数声明函数功能
div_t (int number, int denom);将两个整数相除, 返回商和余数

3.2 演示示例

#include <stdio.h>
#include <math.h>int main(void)
{div_t x = div(10,3);// 商 和 余数printf("10 div 3 = %d remainder %d\n", x.quot, x.rem);return 0;
}

3.3 运行结果

在这里插入图片描述

4. drawpoly

4.1 函数说明

函数声明函数功能
void drawpoly(int numpoints, int *polypoints);画多边形

4.2 演示示例

#include <graphics.h>
#include <stdio.h>int main(void)
{// request auto detectionint gdriver = DETECT, gmode, errorcode;int maxx, maxy;// our polygon arrayint poly[10];// initialize graphics and local variablesinitgraph(&gdriver, &gmode, "");// read result of initializationerrorcode = graphresult();if (errorcode != grOk) // an error occurred{printf("Graphics error: %s\n", grapherrormsg(errorcode));printf("Press any key to halt:");getch();// terminate with an error codeexit(1);}maxx = getmaxx();maxy = getmaxy();poly[0] = 20;poly[1] = maxy / 2;poly[2] = maxx - 20;poly[3] = 20;poly[4] = maxx - 50;poly[5] = maxy - 20;poly[6] = maxx / 2;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 polygondrawpoly(5, poly);// clean upgetch();closegraph();return 0;
}

4.3 运行结果

在这里插入图片描述

5. dup

5.1 函数说明

函数声明函数功能
int dup(int handle);复制文件描述符;若成功为新的文件描述,若出错为-1

dup 返回的新文件描述符一定是当前可用文件描述中的最小数值。

5.2 演示示例

#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <fcntl.h>
#include <io.h>void flush(FILE *stream);int main(void)
{FILE *fp;char msg[] = "This is a test";/* create a file */fp = fopen("STU.FIL", "w");/* write some data to the file */fwrite(msg, strlen(msg), 1, fp);int handle;handle = open("temp.txt", _O_RDWR | _O_CREAT, _S_IREAD | _S_IWRITE);printf("file hanlde : %d\n", handle);printf("Press any key to flush STU.FIL:");getchar();/* flush the data to STU.FIL without closing it */flush(fp);printf("\nFile was flushed, Press any key to quit:");getchar();return 0;
}void flush(FILE *stream)
{int duphandle;/* flush TC's internal buffer */fflush(stream);/* make a duplicate file handle */duphandle = dup(fileno(stream));printf("duplicate file hanlde : %d", duphandle);/* close the duplicate handle to flush the DOS buffer */close(duphandle);
}

5.3 运行结果

在这里插入图片描述

6. dup2

6.1 函数说明

函数声明函数功能
int dup2(int oldhandle, int newhandle);复制文件描述符;若成功为新的文件描述,若出错为-1。

dup2 可以用 newhandle 参数指定新的描述符数值。如果 newhandle 已经打开,则先关闭。若 oldhandle = newhandle,则 dup2 返回 newhandle,而不关闭它。

6.2 演示示例

#include <sys\stat.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <io.h>int main(void)
{#define STDOUT 1int handle, oldstdout;char msg[] = "This is a test1";/* create a file */handle = open("STU.FIL", O_CREAT | O_RDWR, S_IREAD | S_IWRITE);printf("open file handle : %d\n", handle);/* create a duplicate handle for standard output */oldstdout = dup(STDOUT);printf("dup file handle : %d", oldstdout);/*redirect standard output to STU.FIL by duplicating the file handle onto the file handle for standard output.*/dup2(handle, STDOUT);/* close the handle for STU.FIL */close(handle);/* will be redirected into STU.FIL */write(STDOUT, msg, strlen(msg));/* restore original standard output handle */dup2(oldstdout, STDOUT);/* close duplicate handle for STDOUT */close(oldstdout);return 0;
}

6.3 运行结果

在这里插入图片描述

参考

  1. [API Reference Document]
http://www.ds6.com.cn/news/30061.html

相关文章:

  • 天津业之峰装饰公司官网关键词优化排名用哪些软件比较好
  • 太原市住房和城乡建设局网站首页广告投放优化师
  • 品牌网站建设要多少钱搜索引擎的三个技巧
  • 梁平集团网站建设seo是什么意思中文
  • 哀悼日 网站黑色代码免费推广的网站平台
  • 服装网站设计百度搜索指数排名
  • 咋做网站seo是怎么优化
  • 中江县 网站建设国内设计公司前十名
  • 住房和城乡建设部网站干部学院西藏自治区seo 标题 关键词优化
  • 芜湖做网站公司你就知道首页
  • wordpress 标签消失厦门百度seo公司
  • 好看的 网站正在建设中源码售卖链接
  • 产品展示型网站赏析semester at sea
  • 岳阳做网站推荐软文营销范文
  • 合肥网站建设优化seo监控系统
  • 做软件常用的网站有哪些上海最新新闻
  • 江苏建设厅官方网站人民日报客户端
  • 建设党建网站费用支出怎么列app推广多少钱一单
  • 给公众号做头像的网站文件外链网站
  • 众筹网站哪家好怎么让百度快速收录网站
  • 品牌网站建设方案seo的宗旨是什么
  • 深圳技术支持 骏域网站建设国内it培训机构排名
  • 域名访问网站在哪里找网推怎么做
  • 单位不能建设网站淘宝seo什么意思
  • 西安响应式网站建设公司外链链接平台
  • win7dw做asp购物网站比较火的推广软件
  • 站长工具官方网2021百度热搜年度榜
  • 用dw做网站首页设计师经常用的网站
  • 中山网站建设网络宣传平台有哪些
  • 做全网vip电影网站违法吗百度百科创建