文書番号: 402699
最終更新日: 1998/03/23
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <conio.h> #define SIZ 3 #define LEN 67 struct abc{ char s[LEN]; }dat[SIZ]={{"99"},{"22"},{"11"}}; void dspdata(void); int compare(const void *arg1, const void *arg2); void main(void) { printf( "----ソート前----\n"); dspdata(); getch(); qsort( (void *)dat, (size_t)SIZ, sizeof(struct abc), compare); printf( "----ソート後----\n"); dspdata(); getch(); } void dspdata(void) { int i; for(i=0;i<SIZ;i++) printf( "%s\n", dat[i].s ); } int compare(const void *arg1, const void *arg2) { return strcmp(((struct abc *)arg1)->s,((struct abc *)arg2)->s); }
Keywords: KBBUG KB402699
Technology: kbAudDeveloper kbCCompSearch kbQC200 kbZNotKeyword3