Skip to content

Instantly share code, notes, and snippets.

@xnuk
Created May 16, 2014 02:21
Show Gist options
  • Select an option

  • Save xnuk/fd31e2703e74d233b8af to your computer and use it in GitHub Desktop.

Select an option

Save xnuk/fd31e2703e74d233b8af to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include "defines.h"
void forEach(pint a,int size);
void sth(pint d);
void pri(pint d);
int main noparam {
int a[]={0, 3, 2, 7};
forEach(a, 4, sth);
forEach(a, 4, pri);
return 0;
}
void forEach(pint a,int length, pvoid func(int index, pint)){
register int i=0;
for(; i<length; i++){
func(i, a+i);
}
}
void sth(int i, pint d){
(*d)++;
}
void pri(int i, pint d){
printf("%d", *d);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment