ImageVerifierCode 换一换
格式:DOCX , 页数:18 ,大小:18.87KB ,
资源ID:12685968      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/12685968.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C语言函数大全.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C语言函数大全.docx

1、C语言函数大全楼主 Posted:2008-4-16 14:14:09222.240.188.229信息 日志 短讯 邮箱 好友 搜索 引用 回复 C语言函数大全 c函数名: cabs功 能: 计算复数的绝对值用 法: double cabs(struct complex z);程序例: #include #include int main(void) struct complex z; double val; z.x = 2.0; z.y = 1.0; val = cabs(z); printf(The absolute value of %.2lfi %.2lfj is %.2lf, z.

2、x, z.y, val); return 0;函数名: calloc功 能: 分配主存储器用 法: void *calloc(size_t nelem, size_t elsize);程序例:#include #include int main(void) char *str = NULL; /* allocate memory for string */ str = calloc(10, sizeof(char); /* copy Hello into string */ strcpy(str, Hello); /* display string */ printf(String is %s

3、n, str); /* free memory */ free(str); return 0;函数名: ceil功 能: 向上舍入用 法: double ceil(double x);程序例:#include #include int main(void) double number = 123.54; double down, up; down = floor(number); up = ceil(number); printf(original number %5.2lfn, number); printf(number rounded down %5.2lfn, down); print

4、f(number rounded up %5.2lfn, up); return 0;函数名: cgets功 能: 从控制台读字符串用 法: char *cgets(char *str);程序例:#include #include int main(void) char buffer83; char *p; /* Theres space for 80 characters plus the NULL terminator */ buffer0 = 81; printf(Input some chars:); p = cgets(buffer); printf(ncgets read %d c

5、haracters: %sn, buffer1, p); printf(The returned pointer is %p, buffer0 is at %pn, p, &buffer); /* Leave room for 5 characters plus the NULL terminator */ buffer0 = 6; printf(Input some chars:); p = cgets(buffer); printf(ncgets read %d characters: %sn, buffer1, p); printf(The returned pointer is %p,

6、 buffer0 is at %pn, p, &buffer); return 0;函数名: chdir功 能: 改变工作目录用 法: int chdir(const char *path);程序例:#include #include #include char old_dirMAXDIR;char new_dirMAXDIR;int main(void) if (getcurdir(0, old_dir) perror(getcurdir(); exit(1); printf(Current directory is: %sn, old_dir); if (chdir() perror(ch

7、dir(); exit(1); if (getcurdir(0, new_dir) perror(getcurdir(); exit(1); printf(Current directory is now: %sn, new_dir); printf(nChanging back to orignal directory: %sn, old_dir); if (chdir(old_dir) perror(chdir(); exit(1); return 0;函数名: _chmod, chmod功 能: 改变文件的访问方式用 法: int chmod(const char *filename,

8、int permiss);程序例:#include #include #include void make_read_only(char *filename);int main(void) make_read_only(NOTEXIST.FIL); make_read_only(MYFILE.FIL); return 0;void make_read_only(char *filename) int stat; stat = chmod(filename, S_IREAD); if (stat) printf(Couldnt make %s read-onlyn, filename); els

9、e printf(Made %s read-onlyn, filename);函数名: chsize功 能: 改变文件大小用 法: int chsize(int handle, long size);程序例:#include #include #include int main(void) int handle; char buf11 = 0123456789; /* create text file containing 10 bytes */ handle = open(DUMMY.FIL, O_CREAT); write(handle, buf, strlen(buf); /* trun

10、cate the file to 5 bytes in size */ chsize(handle, 5); /* close the file */ close(handle); return 0;函数名: circle功 能: 在给定半径以(x, y)为圆心画圆用 法: void far circle(int x, int y, int radius);程序例:#include #include #include #include int main(void) /* request auto detection */ int gdriver = DETECT, gmode, errorco

11、de; int midx, midy; int radius = 100; /* 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 key

12、to halt:); getch(); exit(1); /* terminate with an error code */ midx = getmaxx() / 2; midy = getmaxy() / 2; setcolor(getmaxcolor(); /* draw the circle */ circle(midx, midy, radius); /* clean up */ getch(); closegraph(); return 0;函数名: cleardevice功 能: 清除图形屏幕用 法: void far cleardevice(void);程序例:#include

13、 #include #include #include int main(void) /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int midx, midy; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an err

14、or occurred */ 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(); /* for centering screen messages */ settextjustify(CENTER_TEXT, CENTER_TEXT);

15、/* output a message to the screen */ outtextxy(midx, midy, press any key to clear the screen:); /* wait for a key */ getch(); /* clear the screen */ cleardevice(); /* output another message */ outtextxy(midx, midy, press any key to quit:); /* clean up */ getch(); closegraph(); return 0;函数名: clearerr

16、功 能: 复位错误标志用 法:void clearerr(FILE *stream);程序例:#include int main(void) FILE *fp; char ch; /* open a file for writing */ fp = fopen(DUMMY.FIL, w); /* force an error condition by attempting to read */ ch = fgetc(fp); printf(%cn,ch); if (ferror(fp) /* display an error message */ printf(Error reading fr

17、om DUMMY.FILn); /* reset the error and EOF indicators */ clearerr(fp); fclose(fp); return 0;函数名: clearviewport功 能: 清除图形视区用 法: void far clearviewport(void);程序例:#include #include #include #include #define CLIP_ON 1 /* activates clipping in viewport */int main(void) /* request auto detection */ int gdr

18、iver = DETECT, gmode, errorcode; int ht; /* 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 */ setcolor(getmaxcolor(); ht = textheight(W); /* message in default full-screen viewport */ outtextxy(0, 0, * - (0, 0) in default viewport); /* create a smaller viewport */ setviewport(50, 50, getmaxx()-50, getmaxy()-50, CLIP_ON); /* d

20、isplay some messages */ outtextxy(0, 0, * - (0, 0) in smaller viewport); outtextxy(0, 2*ht, Press any key to clear viewport:); /* wait for a key */ getch(); /* clear the viewport */ clearviewport(); /* output another message */ outtextxy(0, 0, Press any key to quit:); /* clean up */ getch(); closegr

21、aph(); return 0;函数名: _close, close功 能: 关闭文件句柄用 法: int close(int handle);程序例:#include #include #include #include main() int handle; char buf11 = 0123456789; /* create a file containing 10 bytes */ handle = open(NEW.FIL, O_CREAT); if (handle -1) write(handle, buf, strlen(buf); /* close the file */ clo

22、se(handle); else printf(Error opening filen); return 0;函数名: clock功 能: 确定处理器时间用 法: clock_t clock(void);程序例:#include #include #include int main(void) clock_t start, end; start = clock(); delay(2000); end = clock(); printf(The time was: %fn, (end - start) / CLK_TCK); return 0;函数名: closegraph功 能: 关闭图形系统

23、用 法: void far closegraph(void);程序例:#include #include #include #include int main(void) /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int x, y; /* initialize graphics mode */ initgraph(&gdriver, &gmode, ); /* read result of initialization */ errorcode = graphresult(); if (errorc

24、ode != grOk) /* an error occurred */ printf(Graphics error: %sn, grapherrormsg(errorcode); printf(Press any key to halt:); getch(); exit(1); /* terminate with an error code */ x = getmaxx() / 2; y = getmaxy() / 2; /* output a message */ settextjustify(CENTER_TEXT, CENTER_TEXT); outtextxy(x, y, Press

25、 a key to close the graphics system:); /* wait for a key */ getch(); /* closes down the graphics system */ closegraph(); printf(Were now back in text mode.n); printf(Press any key to halt:); getch(); return 0;函数名: clreol功 能: 在文本窗口中清除字符到行末用 法: void clreol(void);程序例:#include int main(void) clrscr(); cprintf(The function CLREOL clears all characters from thern); cprintf(cursor position to the end of the line within thern); cprintf(current text window, without moving the cursor.rn); cprintf(Press any key to continue . . .); gotoxy(14, 4); getch(); clreol();

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

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