C语言函数库

从今天开始,慢慢的写全c语言函数库的函数使用代码

1.函数名: atoi

功  能: 把字符串转换成长整型数
用  法: int atoi(const char *nptr);需要传进一个char类型的指针
程序例:

#include <stdlib.h>
#include <stdio.h>
int main(void)
{
   int n;
   char *str = "12345.67";
   n = atoi(str);
   printf("string = %s integer = %d\n", str, n);//string = 12345.67 integer = 12345
   return 0;
}

2.abort

功  能: 异常终止一个进程
用  法: void abort(void)
程序例:

#include <stdio.h>

int main(void){
    printf("call abort()\n");//会被执行
    abort();
    printf("call abort()\n");//由于程序的进程被终止了,abort之后的代码都不会被执行。
    return 0;
}

3.函数名: abs

功 能: 求整数的绝对值用 法: int abs(int i);

程序例:

#include <stdio.h>

int main(void){
    int a = -1100;
    printf("利用abs()函数,要显示正整数a = %d\n" , abs(a));//很显然,结果为1100
    return 0;
}

4.函数名:absread , abswrite

功能:绝对磁盘的读和写

用法:int absread(int drive , int nsects , int sectno , void *buffer);

int abswrite(int drive , int nsects , int tsectno , void *buffer);

程序例

 

posted @ 2010-04-11 21:51  云端小飞象cg  阅读(253)  评论(0编辑  收藏  举报