C语言函数大全.docx
《C语言函数大全.docx》由会员分享,可在线阅读,更多相关《C语言函数大全.docx(310页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、AAA.函数名: abort功 能: 异常终止一个进程用 法: void abort(void);程序例:#include #include int main(void) printf(Calling abort()n); abort(); return 0; /* This is never reached */函数名: abs功 能: 求整数的绝对值用 法: int abs(int i);程序例:#include #include int main(void) int number = -1234; printf(number: %d absolute value: %dn, number
2、, abs(number); return 0;函数名: absread, abswirte功 能: 绝对磁盘扇区读、写数据用 法: int absread(int drive, int nsects, int sectno, void *buffer);int abswrite(int drive, int nsects, in tsectno, void *buffer);程序例:/* absread example */#include #include #include #include int main(void) int i, strt, ch_out, sector; char
3、buf512; printf(Insert a diskette into drive A and press any keyn); getch(); sector = 0; if (absread(0, 1, sector, &buf) != 0) perror(Disk problem); exit(1); printf(Read OKn); strt = 3; for (i=0; i80; i+) ch_out = bufstrt+i; putchar(ch_out); printf(n); return(0);函数名: access功 能: 确定文件的访问权限用 法: int acce
4、ss(const char *filename, int amode);程序例:#include #include int file_exists(char *filename);int main(void) printf(Does NOTEXIST.FIL exist: %sn, file_exists(NOTEXISTS.FIL) ? YES : NO); return 0;int file_exists(char *filename) return (access(filename, 0) = 0);函数名: acos功 能: 反余弦函数用 法: double acos(double x
5、);程序例:#include #include int main(void) double result; double x = 0.5; result = acos(x); printf(The arc cosine of %lf is %lfn, x, result); return 0;函数名: allocmem功 能: 分配DOS存储段用 法: int allocmem(unsigned size, unsigned *seg);程序例:#include #include #include int main(void) unsigned int size, segp; int stat
6、; size = 64; /* (64 x 16) = 1024 bytes */ stat = allocmem(size, &segp); if (stat = -1) printf(Allocated memory at segment: %xn, segp); else printf(Failed: maximum number of paragraphs available is %un, stat); return 0;函数名: arc功 能: 画一弧线用 法: void far arc(int x, int y, int stangle, int endangle, int ra
7、dius);程序例:#include #include #include #include int main(void) /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int midx, midy; int stangle = 45, endangle = 135; int radius = 100; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ); /* read result of initial
8、ization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) printf(Graphics error: %sn, grapherrormsg(errorcode); printf(Press any key to halt:); getch(); exit(1); /* terminate with an error code */ midx = getmaxx() / 2; midy = getmaxy() / 2; setcolor(getmaxcolor(); /* draw
9、arc */ arc(midx, midy, stangle, endangle, radius); /* clean up */ getch(); closegraph(); return 0;函数名: asctime功 能: 转换日期和时间为ASCII码用 法: char *asctime(const struct tm *tblock);程序例:#include #include #include int main(void) struct tm t; char str80; /* sample loading of tm structure */ t.tm_sec = 1; /* Se
10、conds */ t.tm_min = 30; /* Minutes */ t.tm_hour = 9; /* Hour */ t.tm_mday = 22; /* Day of the Month */ t.tm_mon = 11; /* Month */ t.tm_year = 56; /* Year - does not include century */ t.tm_wday = 4; /* Day of the week */ t.tm_yday = 0; /* Does not show in asctime */ t.tm_isdst = 0; /* Is Daylight Sa
11、vTime; does not show in asctime */ /* converts structure to null terminated string */ strcpy(str, asctime(&t); printf(%sn, str); return 0;函数名: asin功 能: 反正弦函数用 法: double asin(double x);程序例:#include #include int main(void) double result; double x = 0.5; result = asin(x); printf(The arc sin of %lf is %
12、lfn, x, result); return(0);函数名: assert功 能: 测试一个条件并可能使程序终止用 法: void assert(int test);程序例:#include #include #include struct ITEM int key; int value;/* add item to list, make sure list is not null */void additem(struct ITEM *itemptr) assert(itemptr != NULL); /* add item to list */int main(void) additem
13、(NULL); return 0;函数名: atan功 能: 反正切函数用 法: double atan(double x);程序例:#include #include int main(void) double result; double x = 0.5; result = atan(x); printf(The arc tangent of %lf is %lfn, x, result); return(0);函数名: atan2功 能: 计算Y/X的反正切值用 法: double atan2(double y, double x);程序例:#include #include int m
14、ain(void) double result; double x = 90.0, y = 45.0; result = atan2(y, x); printf(The arc tangent ratio of %lf is %lfn, (y / x), result); return 0;函数名: atexit功 能: 注册终止函数用 法: int atexit(atexit_t func);程序例:#include #include void exit_fn1(void) printf(Exit function #1 calledn);void exit_fn2(void) printf
15、(Exit function #2 calledn);int main(void) /* post exit function #1 */ atexit(exit_fn1); /* post exit function #2 */ atexit(exit_fn2); return 0;函数名: atof功 能: 把字符串转换成浮点数用 法: double atof(const char *nptr);程序例:#include #include int main(void) float f; char *str = 12345.67; f = atof(str); printf(string =
16、 %s float = %fn, str, f); return 0;函数名: atoi功 能: 把字符串转换成长整型数用 法: int atoi(const char *nptr);程序例:#include #include int main(void) int n; char *str = 12345.67; n = atoi(str); printf(string = %s integer = %dn, str, n); return 0;函数名: atol功 能: 把字符串转换成长整型数用 法: long atol(const char *nptr);程序例:#include #inc
17、lude int main(void) long l; char *str = ; l = atol(lstr); printf(string = %s integer = %ldn, str, l); return(0);BBB.函数名: bar功 能: 画一个二维条形图用 法: void far bar(int left, int top, int right, int bottom);程序例: #include #include #include #include int main(void) /* request auto detection */ int gdriver = DETE
18、CT, gmode, errorcode; int midx, midy, i; /* 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 k
19、ey to halt:); getch(); exit(1); /* terminate with an error code */ midx = getmaxx() / 2; midy = getmaxy() / 2; /* loop through the fill patterns */ for (i=SOLID_FILL; iUSER_FILL; i+) /* set the fill style */ setfillstyle(i, getmaxcolor(); /* draw the bar */ bar(midx-50, midy-50, midx+50, midy+50); g
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 函数 大全
限制150内