fork download
  1. #include <stdlib.h>
  2. typedef int(*CompareFuncT)(void *, void *);
  3.  
  4. struct SortedList
  5. {
  6. CompareFuncT comp;
  7. };
  8. typedef struct SortedList * SortedListPtr;
  9.  
  10. SortedListPtr SLCreate(CompareFuncT cf){
  11. SortedListPtr slp = malloc(sizeof(struct SortedList));
  12.  
  13. slp->comp = cf;
  14. return slp;
  15. }
  16.  
  17. int compareInts(void *p1, void *p2)
  18. {
  19. int i1 = *(int*)p1;
  20. int i2 = *(int*)p2;
  21.  
  22. return i1 - i2;
  23. }
  24.  
  25. int main(){
  26. SLCreate(compareInts);
  27. }
Success #stdin #stdout 0s 2180KB
stdin
Standard input is empty
stdout
Standard output is empty