C语言库函数(C类字母).doc

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
C语言库函数(C类字母)

C语言库函数(C类字母) C语言库函数(C类字母) 函数名: cabs 功 能: 计算复数的绝对值 用 法: double cabs(struct complex z); 程序例: #include stdio.h #include math.h 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.x, z.y, val); return 0; } 函数名: calloc 功 能: 分配主存储器 用 法: void *calloc(size_t nelem, size_t elsize); 程序例: #include stdio.h #include alloc.h 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\n, str); /* free memory */ free(str); return 0; } 函数名: ceil 功 能: 向上舍入 用 法: double ceil(double x); 程序例: #include math.h #include stdio.h int main(void) { double number = 123.54; double down, up; down = floor(number); up = ceil(number); printf(original number %5.2lf\n, number); printf(number rounded down %5.2lf\n, down); printf(number rounded up %5.2lf\n, up); return 0; } 函数名: cgets 功 能: 从控制台读字符串 用 法: char *cgets(char *str); 程序例: #include stdio.h #include conio.h int main(void) { char buffer[83]; char *p; /* Theres space for 80 characters plus the NULL terminator */ buffer[0] = 81; printf(Input some chars:); p = cgets(buffer); printf(\ncgets read %d characters: \%s\\n, buffer[1], p); printf(The returned pointer is %p, buffer[0] is at %p\n, p, buffer); /* Leave room for 5 characters plus the NULL terminator */ buffer[0] = 6; printf(Input some chars:); p = cgets(buffer); printf(\ncgets read %d characters: \%s\\n, buffer[1], p); printf(The returned pointer is %p, buffer[0] is at %p\n, p, buffer); return 0; } 函数名: chdir 功 能: 改变工作目录 用 法: int chdir(const char *path); 程序例: #include stdio.h #include stdlib.h #include dir.h char old_dir[MAXDIR]; char new_dir[MAXDIR]; int main(void) { if (getcurdir(0, old_dir)) { perror(getcurdir()); exit(1); } printf(Current directory is: \\%s\n, old_dir); if (chdir(\\)

文档评论(0)

pep2233 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档