parent
b554018319
commit
7d7ac8ec82
@ -0,0 +1,37 @@ |
|||||||
|
#include <stdio.h> |
||||||
|
#include <stdlib.h> |
||||||
|
|
||||||
|
void someFunction(int arg) |
||||||
|
{ |
||||||
|
printf("This is someFunction being called and arg is: %d\n", arg); |
||||||
|
printf("Now, leaving the funciton!\n"); |
||||||
|
} |
||||||
|
|
||||||
|
int compare(const void* left, const void* right) |
||||||
|
{ |
||||||
|
return (*(int*)right - *(int*)left); |
||||||
|
} |
||||||
|
|
||||||
|
int main() |
||||||
|
{ |
||||||
|
void (*pf)(int); |
||||||
|
pf = &someFunction; |
||||||
|
printf("We are about to call someFunction() using a pointer!\n"); |
||||||
|
(pf)(5); |
||||||
|
printf("Wow that was cool!"); |
||||||
|
|
||||||
|
int (*cmp)(const void*, const void*); |
||||||
|
cmp = &compare; |
||||||
|
|
||||||
|
int iarray[] = {1,2,3,4,7,5,6,9,8}; |
||||||
|
qsort(iarray, sizeof(iarray) / sizeof(*iarray), sizeof(*iarray), cmp); |
||||||
|
|
||||||
|
int c = 0; |
||||||
|
while (c < sizeof(iarray) / sizeof(*iarray)) |
||||||
|
{ |
||||||
|
printf("%d\t", iarray[c]); |
||||||
|
c++; |
||||||
|
} |
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
Loading…
Reference in new issue