C语言函数大全-c开头-完整版

上传人:s9****2 文档编号:558562574 上传时间:2022-09-11 格式:DOC 页数:16 大小:36.50KB
返回 下载 相关 举报
C语言函数大全-c开头-完整版_第1页
第1页 / 共16页
C语言函数大全-c开头-完整版_第2页
第2页 / 共16页
C语言函数大全-c开头-完整版_第3页
第3页 / 共16页
C语言函数大全-c开头-完整版_第4页
第4页 / 共16页
C语言函数大全-c开头-完整版_第5页
第5页 / 共16页
点击查看更多>>
资源描述

《C语言函数大全-c开头-完整版》由会员分享,可在线阅读,更多相关《C语言函数大全-c开头-完整版(16页珍藏版)》请在金锄头文库上搜索。

1、文档供参考,可复制、编制,期待您的好评与关注! C语言函数大全(c开头)函数名: cabs功能: 计算复数的绝对值用法: double cabs(struct complex z);程序例:#include#includeint 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.x, z.y, val);return 0;函数名: calloc功能: 分配主存储器用法: void *callo

2、c(size_t nelem, size_t elsize);程序例:#include#includeint 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 %sn, str);/* free memory */free(str);return 0;函数名: ceil功能: 向上舍入用法: doubl

3、e ceil(double x);程序例:#include#includeint 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);printf(number rounded up %5.2lfn, up);return 0;函数名: cgets功能: 从控制台读字符串用法: char *cgets(char

4、 *str);程序例:#include#includeint 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 characters: %sn, buffer1, p);printf(The returned pointer is %p, buffer0 is at %pn, p, &buffer);/*

5、 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, buffer0 is at %pn, p, &buffer);return 0;函数名: chdir功能: 改变工作目录用法: int chdir(const char *path);程序例:#inclu

6、de#include#includechar 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(chdir();exit(1);if (getcurdir(0, new_dir)perror(getcurdir();exit(1);printf(Current directory is now: %sn, new_dir);pr

7、intf(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, int permiss);程序例:#include#include#includevoid make_read_only(char *filename);int main(void)make_read_only(NOTEXIST.FIL);make_re

8、ad_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);elseprintf(Made %s read-onlyn, filename);函数名: chsize功能: 改变文件大小用法: int chsize(int handle, long size);程序例:#include#include#includeint main(void

9、)int handle;char buf11 = 0123456789;/* create text file containing 10 bytes */handle = open(DUMMY.FIL, O_CREAT);write(handle, buf, strlen(buf);/* truncate the file to 5 bytes in size */chsize(handle, 5);/* close the file */close(handle);return 0;函数名: circle功能: 在给定半径以(x, y)为圆心画圆用法: void far circle(in

10、t x, int y, int radius);程序例:#include#include#include#includeint main(void)/* request auto detection */int gdriver = DETECT, gmode, errorcode;int midx, midy;int radius = 100;/* initialize graphics and local variables */initgraph(&gdriver, &gmode, );/* read result of initialization */errorcode = graph

11、result();if (errorcode != grOk) /* an error 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();/* draw the circle */circle(midx, midy, radiu

12、s);/* clean up */getch();closegraph();return 0;函数名: cleardevice功能: 清除图形屏幕用法: void far cleardevice(void);程序例:#include#include#include#includeint main(void)/* request auto detection */int gdriver = DETECT, gmode, errorcode;int midx, midy;/* initialize graphics and local variables */initgraph(&gdriver,

13、 &gmode, );/* read result of initialization */errorcode = graphresult();if (errorcode != grOk) /* an error 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;setco

14、lor(getmaxcolor();/* for centering screen messages */settextjustify(CENTER_TEXT, CENTER_TEXT);/* 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功能: 复位错误标志用法:void clearerr(FILE *stream);程序例:#includeint main(void

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 国内外标准规范

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号