C语言函数大全q,r开头详细版.docVIP

  • 2
  • 0
  • 约9.28千字
  • 约 12页
  • 2018-11-16 发布于江苏
  • 举报
C语言函数大全q,r开头详细版

C语言函数大全(q,r开头) 函数名: qsort 功能: 使用快速排序例程进行排序 用法: void qsort(void *base, int nelem, int width, int (*fcmp)()); 程序例: #include #include #include int sort_function( const void *a, const void *b); char list[5][4] = { cat, car, cab, cap, can }; int main(void) { int x; qsort((void *)list, 5, sizeof(list[0]), sort_function); for (x = 0; x 5; x++) printf(%s\n, list[x]); return 0; } int sort_function( const void *a, const void *b) { return( strcmp(a,b) ); } 函数名: qsort 功能: 使用快速排序例程进行排序 用法: void qsort(void *base, int nelem, int width, int (*fcmp)()); 程序例: #include #include #include int sort_function( const void *a, const void *b); char list[5][4] = { cat, car, cab, cap, can }; int main(void) { int x; qsort((void *)list, 5, sizeof(list[0]), sort_function); for (x = 0; x 5; x++) printf(%s\n, list[x]); return 0; } int sort_function( const void *a, const void *b) { return( strcmp(a,b) ); } 函数名: raise 功能: 向正在执行的程序发送一个信号 用法: int raise(int sig); 程序例: #include int main(void) { int a, b; a = 10; b = 0; if (b == 0) /* preempt divide by zero error */ raise(SIGFPE); a = a / b; return 0; } 函数名: rand 功能: 随机数发生器 用法: void rand(void); 程序例: #include #include int main(void) { int i; printf(Ten random numbers from 0 to 99\n\n); for(i=0; i10; i++) printf(%d\n, rand() % 100); return 0; } 函数名: randbrd 功能: 随机块读 用法: int randbrd(struct fcb *fcbptr, int reccnt); 程序例: #include #include #include #include int main(void) { char far *save_dta; char line[80], buffer[256]; struct fcb blk; int i, result; /* get user input file name for dta */ printf(Enter drive and file name (no path - i.e. a:file.dat)\n); gets(line); /* put file name in fcb */ if (!parsfnm(line, blk, 1)) { printf(Error in call to parsfnm\n); exit(1); } printf(Drive #%d File: %s\n\n, blk.fcb_drive, blk.fcb_name); /* open file with DOS FCB open file */ bdosptr(0x0F, blk, 0); /* save old dta, and set new one */ save_dta = getdta(); setdta(buffer); /* set up info for the new dta */ blk.fcb_recsize = 128; blk.fcb_random = 0L; result = randbrd(blk,

文档评论(0)

1亿VIP精品文档

相关文档