本程序演示了C语言中回调函数的使用方法

来源:互联网 发布:连尚网络是什么 编辑:程序博客网 时间:2024/04/29 05:40
/******************************************
功能描述:本程序演示了C语言中回调函数的使用方法
作者:陈家朋
日期:2004-1-15
***************************************/
#include <stdio.h>
#include <stdlib.h>


int sort_function( const void *a, const void *b);
int list[5] = { 54, 21, 11, 67, 22 };


int main(void)
{
   int  x;


   qsort((void *)list, 5, sizeof(list[0]), sort_function);
   for (x = 0; x < 5; x++)
      printf("%i\n", list[x]);
   return 0;
}


int sort_function( const void *a, const void *b)
{
   return *(int*)a-*(int*)b;
}
0 0
原创粉丝点击