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(" . 2 lfi %.2lfj的绝对值为% . 2 lf ",z.x,z.y,val);
返回0;
}
函数名:calloc
函数:分配主存
用法:void * calloc (size _ tenelem,size _ telsize);
程序示例:
# include
# include
int main(void)
{
char * str = null;
/*为string */
str = calloc(10,sizeof(char))分配内存;
/*将“Hello”复制到string */
strcpy(str," Hello ");
/* display String */
printf(" String is % s \ n ",str);
/*空闲内存*/
free(str);
返回0;
}
0条评论