不多见但是实用的部分C函数(1)

1.abs :求绝对值

头文件:math.h   或者 stdlib.h

int abs( int n );

The abs function returns the absolute value of its parameter

2.atoi:转化数字字符串为数字

头文件:stdlib.h

int atoi (const char * str);

Convert string to integer

On success, the function returns the converted integral number as an int value.

3.qsort:实现对任意内容的大小排序

头文件:stdlib.h

void qsort (void* base, size_t num, size_t size,
            int (*compar)(const void*,const void*));

base为指针起点 Pointer to the first object of the array to be sorted, converted to a void*

num为比较的元素个数 Number of elements in the array pointed to by base.

size是每个元素的大小(常借助sizeof)Size in bytes of each element in the array.

int (*compar)(const void*,const void*) 该函数指针是需要被调用的比较函数(该函数的目的是,为了让base指向的num个元素,可以反复利用该函数比较大小)

最后,英语阅读能力很重要。C被西方人创造完善,多数文献还是英文原著,最有营养!

推荐学习网站cplusplus.com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值