c语言库函数大全abWord格式.docx

上传人:b****6 文档编号:17292647 上传时间:2022-12-01 格式:DOCX 页数:15 大小:19.33KB
下载 相关 举报
c语言库函数大全abWord格式.docx_第1页
第1页 / 共15页
c语言库函数大全abWord格式.docx_第2页
第2页 / 共15页
c语言库函数大全abWord格式.docx_第3页
第3页 / 共15页
c语言库函数大全abWord格式.docx_第4页
第4页 / 共15页
c语言库函数大全abWord格式.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

c语言库函数大全abWord格式.docx

《c语言库函数大全abWord格式.docx》由会员分享,可在线阅读,更多相关《c语言库函数大全abWord格式.docx(15页珍藏版)》请在冰豆网上搜索。

c语言库函数大全abWord格式.docx

,number,abs(number));

absread,abswirte

绝对磁盘扇区读、写数据

intabsread(intdrive,intnsects,intsectno,void*buffer);

intabswrite(intdrive,intnsects,intsectno,void*buffer);

/*absreadexample*/

conio.h>

process.h>

dos.h>

inti,strt,ch_out,sector;

charbuf[512];

InsertadisketteintodriveAandpressanykey\n"

getch();

sector=0;

if(absread(0,1,sector,&

buf)!

=0)

perror("

Diskproblem"

exit

(1);

}

ReadOK\n"

strt=3;

for(i=0;

i<

80;

i++)

ch_out=buf[strt+i];

putchar(ch_out);

\n"

return(0);

access

确定文件的访问权限

intaccess(constchar*filename,intamode);

io.h>

intfile_exists(char*filename);

DoesNOTEXIST.FILexist:

%s\n"

file_exists("

NOTEXISTS.FIL"

)?

"

YES"

:

NO"

intfile_exists(char*filename)

return(access(filename,0)==0);

acos

反余弦函数

doubleacos(doublex);

doubleresult;

doublex=0.5;

result=acos(x);

Thearccosineof%lfis%lf\n"

x,result);

allocmem

分配DOS存储段

intallocmem(unsignedsize,unsigned*seg);

alloc.h>

unsignedintsize,segp;

intstat;

size=64;

/*(64x16)=1024bytes*/

stat=allocmem(size,&

segp);

if(stat==-1)

Allocatedmemoryatsegment:

%x\n"

segp);

else

Failed:

maximumnumberofparagraphsavailableis%u\n"

stat);

arc

画一弧线

voidfararc(intx,inty,intstangle,intendangle,intradius);

graphics.h>

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

intmidx,midy;

intstangle=45,endangle=135;

intradius=100;

/*initializegraphicsandlocalvariables*/

initgraph(&

gdriver,&

gmode,"

"

/*readresultofinitialization*/

errorcode=graphresult();

/*anerroroccurred*/

if(errorcode!

=grOk)

Graphicserror:

grapherrormsg(errorcode));

Pressanykeytohalt:

/*terminatewithanerrorcode*/

midx=getmaxx()/2;

midy=getmaxy()/2;

setcolor(getmaxcolor());

/*drawarc*/

arc(midx,midy,stangle,endangle,radius);

/*cleanup*/

closegraph();

asctime

转换日期和时间为ASCII码

char*asctime(conststructtm*tblock);

string.h>

time.h>

structtmt;

charstr[80];

/*sampleloadingoftmstructure*/

t.tm_sec=1;

/*Seconds*/

t.tm_min=30;

/*Minutes*/

t.tm_hour=9;

/*Hour*/

t.tm_mday=22;

/*DayoftheMonth*/

t.tm_mon=11;

/*Month*/

t.tm_year=56;

/*Year-doesnotincludecentury*/

t.tm_wday=4;

/*Dayoftheweek*/

t.tm_yday=0;

/*Doesnotshowinasctime*/

t.tm_isdst=0;

/*IsDaylightSavTime;

doesnotshowinasctime*/

/*convertsstructuretonullterminated

string*/

strcpy(str,asctime(&

t));

%s\n"

str);

asin

反正弦函数

doubleasin(doublex);

result=asin(x);

Thearcsinof%lfis%lf\n"

assert

测试一个条件并可能使程序终止

voidassert(inttest);

assert.h>

structITEM{

intkey;

intvalue;

};

/*additemtolist,makesurelistisnotnull*/

voidadditem(structITEM*itemptr){

assert(itemptr!

=NULL);

/*additemtolist*/

additem(NULL);

atan

反正切函数

doubleatan(doublex);

result=atan(x);

Thearctangentof%lfis%lf\n"

atan2

计算Y/X的反正切值

doubleatan2(doubley,doublex);

doublex=90.0,y=45.0;

result=atan2(y,x);

Thearctangentratioof%lfis%lf\n"

(y/x),result);

atexit

注册终止函数

intatexit(atexit_tfunc);

voidexit_fn1(void)

Exitfunction#1called\n"

voidexit_fn2(void)

Exitfunction#2called\n"

/*postexitfunction#1*/

atexit(exit_fn1);

/*postexitfunction#2*/

atexit(exit_fn2);

atof

把字符串转换成浮点数

doubleatof(constchar*nptr);

floatf;

char*str="

12345.67"

;

f=atof(str);

string=%sfloat=%f\n"

str,f);

atoi

把字符串转换成长整型数

intatoi(constchar*nptr);

intn;

n=atoi(str);

string=%sinteger=%d\n"

str,n);

atol

longatol(constchar*nptr);

longl;

98765432"

l=atol(lstr);

string=%sinteger=%ld\n"

str,l);

bar

画一个二维条形图

voidfarbar(intleft,inttop,intright,intbottom);

intmidx,midy,i;

=grOk)/*anerroroccurred*/

/*loopthroughthefillpatterns*/

for(i=SOLID_FILL;

USER_FILL;

/*setthefillstyle*/

setfillstyle(i,getmaxcolor());

/*drawthebar*/

bar(midx-50,midy-50,midx+50,

midy+50);

bar3d

画一个三维条形图

voidfarbar3d(intleft,inttop,intright,intbottom,

intdepth,inttopflag);

/*initializegraphics,localvariables*/

/*terminatewitherrorcode*/

for(i=EMPTY_FILL;

/*drawthe3-dbar*/

bar3d(midx-50,midy-50,midx+50,midy+50,10,1);

bdos

DOS系统调用

intbdos(intdosfun,unsigneddosdx,unsigneddosal);

/*Getcurrentdriveas'

A'

'

B'

...*/

charcurrent_drive(void)

charcurdrive;

/*Getcurrentdiskas0,1,...*/

curdrive=bdos(0x19,0,0);

return('

+curdrive);

Thecurrentdriveis%c:

current_drive());

bdosptr

intbdosptr(intdosfun,void*argument,unsigneddosal);

dir.h>

errno.h>

#defineBUFLEN80

charbuffer[BUFLEN];

inttest;

Enterfullpathnameofadirectory\n"

gets(buffer);

test=bdosptr(0x3B,buffer,0);

if(test)

DOSerrormessage:

errno);

/*Seeerrno.hforerrorlistings*/

exit

(1);

getcwd(buffer,BUFLEN);

Thecurrentdirectoryis:

buffer);

bioscom

串行I/O通信

intbioscom(intcmd,charabyte,intport);

bios.h>

#defineCOM10

#defineDATA_READY0x100

#defineTRUE1

#defineFALSE0

#defineSETTINGS(0x80|0x02|0x00|0x00)

intin,out,status,DONE=FALSE;

bioscom(0,SETTINGS,COM1);

cprintf("

...BIOSCOM[ESC]toexit...\n"

while(!

DONE)

status=bioscom(3,0,COM1);

if(status&

DATA_READY)

if((out=bioscom(2,0,COM1)&

0x7F)!

putch(out);

if(kbhit())

if((in=getch())=='

\x1B'

DONE=TRUE;

bioscom(1,in,COM1);

biosdisk

软硬盘I/O

intbiosdisk(intcmd,intdrive,inthead,inttrack,intsector

intnsects,void*buffer);

#in

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1