c语言函数名称详解 c语言函数名有哪些( 三 )


时间操作函数 得到处理器时间 clock
得到时间差 difftime
设置时间 mktime
得到时间 time
时间转换函数 得到以ASCII码表示的时间 asctime
得到字符串表示的时间 ctime
得到指定格式的时间 strftime
函数库未来的发展方向
本部分用于说明各类别函数库在将来如何发展 。
序号 库类别 头文件 详细说明
1 错误处理 errno.h
2 字符处理 ctype.h
3 地区化 local.h
4 数学函数 math.h
5 信号处理 signal.h
6 输入输出 stdio.h
7 实用工具程序 stdlib.h
8 字符串处理 string.h
C语言中函数名怎样定义函数名就是一个标识符c语言函数名称详解 , 以字母或_(下划线)开始c语言函数名称详解,后接任意数量c语言函数名称详解的字母或数字或_(下划线)c语言函数名称详解的组合 。
因此,A不行,不能包含—,C不行,不能以数字开始,D不行,不能有$符号 。
答案是B 。
详细的C语言函数介绍函数名: cleardevice
功能: 清除图形屏幕
用法: void far cleardevice(void);
程序例:
#include graphics.h
#include stdlib.h
#include stdio.h
#include conio.h
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 error occurred */
{
printf("Graphics error: %s/n", 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);
/* 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;
}
C语言函数的含义 C语言的发展颇为有趣,它的原型ALGOL 60语言 。那么大家知道C语言函数是什么吗?下面一起来看看!
函数(Function)是一段可以重复使用的代码 , 这是从整体上对函数的认识 。
C语言本身带了很多库函数,并分门别类地放在了不同的头文件中,使用时只要引入对应的头文件即可 。
除了C语言自带的.函数 , 我们也可以编写自己的函数,称为自定义函数(User-Defined Function) 。自定义函数和库函数没有本质的区别,表现形式和使用方法一样 , 只是开发者不同而已 。
这一章我们就来讲解如何编写和使用自己的函数 。
参数
函数的一个明显特征就是使用时带括号( ),必要的话 , 括号中还要包含数据或变量 , 称为参数(Parameter) 。参数是函数需要处理的数据,例如:
strlen(str1)用来计算字符串的长度,str1就是参数 。
puts("C语言中文网")用来输出字符串,"C语言中文网"就是参数 。
返回值
既然函数可以处理数据,那就有必要将处理结果告诉我们,所以很多函数都有返回值(Return Value) 。所谓返回值 , 就是函数的执行结果 。例如:
char str1[] = "C Language";
int len = strlen(str1);
strlen() 的处理结果是字符串 str1 的长度,是一个整数 , 我们通过 len 变量来接收 。
函数返回值有固定的数据类型(int、char、float等),用来接收返回值的变量类型要一致 。

推荐阅读