C语言函数大全A开头.docx
- 文档编号:8767291
- 上传时间:2023-02-01
- 格式:DOCX
- 页数:12
- 大小:17.36KB
C语言函数大全A开头.docx
《C语言函数大全A开头.docx》由会员分享,可在线阅读,更多相关《C语言函数大全A开头.docx(12页珍藏版)》请在冰豆网上搜索。
C语言函数大全A开头
C语言函数大全列表——A开头
-
函数名:
abort
功能:
异常终止一个进程
用法:
voidabort(void);
程序例:
1.#include
2.#include
3.int main(void)
4.{
5.printf("Calling abort()\n");
6.abort();
7.return 0; /* This is never reached */
8.}
函数名:
abs
功能:
求整数的绝对值
用法:
intabs(inti);
程序例:
1.#include
2.#include
3.
4.int main(void)
5.{
6.int number = -1234;
7.
8.printf("number:
%d absolute value:
%d\n", number, abs(number));
9.return 0;
10.}
函数名:
absread,abswirte
功能:
绝对磁盘扇区读、写数据
用法:
intabsread(intdrive,intnsects,intsectno,void*buffer);
intabswrite(intdrive,intnsects,intsectno,void*buffer);
程序例:
1./* absread example */
2.
3.#include
4.#include
5.#include
6.#include
7.
8.int main(void)
9.{
10.int i, strt, ch_out, sector;
11.char buf[512];
12.
13.printf("Insert a diskette into drive A and press any key\n");
14.getch();
15.sector = 0;
16.if (absread(0, 1, sector, &buf) !
= 0)
17.{
18.perror("Disk problem");
19.exit
(1);
20.}
21.printf("Read OK\n");
22.strt = 3;
23.for (i=0; i<80; i++)
24.{
25.ch_out = buf[strt+i];
26.putchar(ch_out);
27.}
28.printf("\n");
29.return(0);
30.}
函数名:
access
功能:
确定文件的访问权限
用法:
intaccess(constchar*filename,intamode);
程序例:
1.#include
2.#include
3.
4.int file_exists(char *filename);
5.
6.int main(void)
7.{
8.printf("Does NOTEXIST.FIL exist:
%s\n",
9.file_exists("NOTEXISTS.FIL") ?
"YES" :
"NO");
10.return 0;
11.}
12.
13.int file_exists(char *filename)
14.{
15.return (access(filename, 0) == 0);
16.}
函数名:
acos
功能:
反余弦函数
用法:
doubleacos(doublex);
程序例:
1.#include
2.#include
3.
4.int main(void)
5.{
6.double result;
7.double x = 0.5;
8.
9.result = acos(x);
10.printf("The arc cosine of %lf is %lf\n", x, result);
11.return 0;
12.}
函数名:
allocmem
功能:
分配DOS存储段
用法:
intallocmem(unsignedsize,unsigned*seg);
程序例:
1.#include
2.#include
3.#include
4.
5.int main(void)
6.{
7.unsigned int size, segp;
8.int stat;
9.
10.size = 64; /* (64 x 16) = 1024 bytes */
11.stat = allocmem(size, &segp);
12.if (stat == -1)
13.printf("Allocated memory at segment:
%x\n", segp);
14.else
15.printf("Failed:
maximum number of paragraphs available is %u\n",
16.stat);
17.
18.return 0;
19.}
函数名:
arc
功能:
画一弧线
用法:
voidfararc(intx,inty,intstangle,intendangle,intradius);
程序例:
1.#include
2.#include
3.#include
4.#include
5.
6.int main(void)
7.{
8./* request auto detection */
9.int gdriver = DETECT, gmode, errorcode;
10.int midx, midy;
11.int stangle = 45, endangle = 135;
12.int radius = 100;
13.
14./* initialize graphics and local variables */
15.initgraph(&gdriver, &gmode, "");
16.
17./* read result of initialization */
18.errorcode = graphresult(); /* an error occurred */
19.if (errorcode !
= grOk)
20.{
21.printf("Graphics error:
%s\n", grapherrormsg(errorcode));
22.printf("Press any key to halt:
");
23.getch();
24.
25.exit
(1); /* terminate with an error code */
26.}
27.
28.midx = getmaxx() / 2;
29.midy = getmaxy() / 2;
30.setcolor(getmaxcolor());
31.
32./* draw arc */
33.arc(midx, midy, stangle, endangle, radius);
34.
35./* clean up */
36.getch();
37.closegraph();
38.return 0;
39.}
函数名:
asctime
功能:
转换日期和时间为ASCII码
用法:
char*asctime(conststructtm*tblock);
程序例:
1.#include
2.#include
3.#include
4.
5.int main(void)
6.{
7.struct tm t;
8.char str[80];
9.
10./* sample loading of tm structure */
11.
12.t.tm_sec = 1; /* Seconds */
13.t.tm_min = 30; /* Minutes */
14.t.tm_hour = 9; /* Hour */
15.t.tm_mday = 22; /* Day of the Month */
16.t.tm_mon = 11; /* Month */
17.t.tm_year = 56; /* Year - does not include century */
18.t.tm_wday = 4; /* Day of the week */
19.t.tm_yday = 0; /* Does not show in asctime */
20.t.tm_isdst = 0; /* Is Daylight SavTime; does not show in asctime */
21.
22./* converts structure to null terminated
23.string */
24.
25.strcpy(str, asctime(&t));
26.printf("%s\n", str);
27.
28.return 0;
29.}
函数名:
asin
功能:
反正弦函数
用法:
doubleasin(doublex);
程序例:
1.#include
2.#include
3.
4.int main(void)
5.{
6.double result;
7.double x = 0.5;
8.
9.result = asin(x);
10.printf("The arc sin of %lf is %lf\n", x, result);
11.return(0);
12.}
函数名:
assert
功能:
测试一个条件并可能使程序终止
用法:
voidassert(inttest);
程序例:
1.#include
2.#include
3.#include
4.
5.struct ITEM {
6.int key;
7.int value;
8.};
9.
10./* add item to list, make sure list is not null */
11.void additem(struct ITEM *itemptr) {
12.assert(itemptr !
= NULL);
13./* add item to list */
14.}
15.
16.int main(void)
17.{
18.additem(NULL);
19.return 0;
20.}
函数名:
atan
功能:
反正切函数
用法:
doubleatan(doublex);
程序例:
1.#include
2.#include
3.
4.int main(void)
5.{
6.double result;
7.double x = 0.5;
8.
9.result = atan(x);
10.printf("The arc tangent of %lf is %lf\n", x, result);
11.return(0);
12.}
函数名:
atan2
功能:
计算Y/X的反正切值
用法:
doubleatan2(doubley,doublex);
程序例:
1.#include
2.#include
3.
4.int main(void)
5.{
6.double result;
7.double x = 90.0, y = 45.0;
8.
9.result = atan2(y, x);
10.printf("The arc tangent ratio of %lf is %lf\n", (y / x), result);
11.return 0;
12.}
函数名:
atexit
功能:
注册终止函数
用法:
intatexit(atexit_tfunc);
程序例:
1.#include
2.#include
3.
4.void exit_fn1(void)
5.{
6.printf("Exit function #1 called\n");
7.}
8.
9.void exit_fn2(void)
10.{
11.printf("Exit function #2 called\n");
12.}
13.
14.int main(void)
15.{
16./* post exit function #1 */
17.atexit(exit_fn1);
18./* post exit function #2 */
19.atexit(exit_fn2);
20.return 0;
21.}
函数名:
atof
功能:
把字符串转换成浮点数
用法:
doubleatof(constchar*nptr);
程序例:
1.#include
2.#include
3.
4.int main(void)
5.{
6.float f;
7.char *str = "12345.67";
8.
9.f = atof(str);
10.printf("string = %s float = %f\n", str, f);
11.return 0;
12.}
函数名:
atoi
功能:
把字符串转换成长整型数
用法:
intatoi(constchar*nptr);
程序例:
1.#include
2.#include
3.
4.int main(void)
5.{
6.int n;
7.char *str = "12345.67";
8.
9.n = atoi(str);
10.printf("string = %s integer = %d\n", str, n);
11.return 0;
12.}
函数名:
atol
功能:
把字符串转换成长整型数
用法:
longatol(constchar*nptr);
程序例:
1.#include
2.#include
3.
4.int main(void)
5.{
6.long l;
7.char *str = "98765432";
8.
9.l = atol(lstr);
10.printf("string = %s integer = %ld\n", str, l);
11.return(0);
12.}
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 函数 大全 开头