c语言常用函数手册 chm格式Word格式.docx
- 文档编号:21396749
- 上传时间:2023-01-30
- 格式:DOCX
- 页数:12
- 大小:16.53KB
c语言常用函数手册 chm格式Word格式.docx
《c语言常用函数手册 chm格式Word格式.docx》由会员分享,可在线阅读,更多相关《c语言常用函数手册 chm格式Word格式.docx(12页珍藏版)》请在冰豆网上搜索。
/*Thisisneverreached*/
}
abs
求整数的绝对值
intabs(inti);
math.h>
intnumber=-1234;
number:
%d
absolutevalue:
%d\n"
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
/*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);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- c语言常用函数手册 chm格式 语言 常用 函数 手册 chm 格式