设为首页 加入收藏

TOP

此C语言函数---A(二)
2014-11-23 19:18:54 来源: 作者: 【 】 浏览:21
Tags:语言 函数 ---A

用 法: void assert(int test);

程序例:

#include 
  
    
#include 
   
     #include 
    
      struct ITEM { int key; int value; }; /* add item to list, make sure list is not null */ void additem(struct ITEM *itemptr) { assert(itemptr != NULL); /* add item to list */ } int main(void) { additem(NULL); return 0; } 
    
   
  

函数名: atan

功 能: 反正切函数

用 法: double atan(double x);

程序例:

#include 
  
    
#include 
   
     int main(void) { double result; double x = 0.5; result = atan(x); printf("The arc tangent of %lf is %lf\n", x, result); return(0); } 
   
  

函数名: atan2

功 能: 计算Y/X的反正切值

用 法: double atan2(double y, double x);

程序例:

#include 
  
    
#include 
   
     int main(void) { double result; double x = 90.0, y = 45.0; result = atan2(y, x); printf("The arc tangent ratio of %lf is %lf\n", (y / x), result); return 0; } 
   
  

函数名: atexit

功 能: 注册终止函数

用 法: int atexit(atexit_t func);

程序例:

#include 
  
    
#include 
   
     void exit_fn1(void) { printf("Exit function #1 called\n"); } void exit_fn2(void) { printf("Exit function #2 called\n"); } int main(void) { /* post exit function #1 */ atexit(exit_fn1); /* post exit function #2 */ atexit(exit_fn2); return 0; } 
   
  

函数名: atof

功 能: 把字符串转换成浮点数

用 法: double atof(const char *nptr);

程序例:

#include 
  
    
#include 
   
     int main(void) { float f; char *str = "12345.67"; f = atof(str); printf("string = %s float = %f\n", str, f); return 0; } 
   
  

函数名: atoi

功 能: 把字符串转换成长整型数

用 法: int atoi(const char *nptr);

程序例:

#include 
  
    
#include 
   
     int main(void) { int n; char *str = "12345.67"; n = atoi(str); printf("string = %s integer = %d\n", str, n); return 0; } 
   
  

函数名: atol

功 能: 把字符串转换成长整型数

用 法: long atol(const char *nptr);

程序例:

#include 
  
    
#include 
   
     int main(void) { long l; char *str = "98765432"; l = atol(lstr); printf("string = %s integer = %ld\n", str, l); return(0); } 
   
  



由 书画小说软件 整理 更惬意的读、更舒心的写、更轻松的发布
首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Objective-C总Runtime的那点事儿.. 下一篇C语言非递归实现二叉树的先序、中..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: